Verfasst am: 12.01.2011, 10:38
Titel: Problem mit Parent bei createfigure
Hallo zusammen,
ich versuche gerade einen scatter-plot zu erstellen, bei dem oben rechts innerhalb der Abbildung ein bar-chart zu sehen ist.
Mit dem Editor habe ich das schön hinbekommen und mir auch das m.file dazu ausgeben lassen.
Wie ich createfigure aufrufe weiß ich und die zu plottenden Daten habe ich auch übergeben.
Um den barchart zu erstellen will er aber auch ein "bar parent" haben, das müsste doch eine Positionsangabe für den chart sein, oder?
Ich habe zum Testen schon einen einfachen Vektor [1,2,3] eingegeben, aber da scheint er ein Problem mit dem Format zu haben.
Welches Format brauche ich dafür, bzw. wie muss die Eingabe für den Parent aufgebaut sein?
Vielen Dank schonmal!
Hier nochmal der Code für createfigure:
Code:
function createfigure(X1, YMatrix1, yvector1, Parent1)
%CREATEFIGURE(X1,YMATRIX1,YVECTOR1,PARENT1) % X1: vector of x data % YMATRIX1: matrix of y data % YVECTOR1: bar yvector % PARENT1: bar parent
% Auto-generated by MATLAB on 11-Jan-2011 16:55:00
% Create axes
axes1 = axes('Parent',figure1,...
'Position',[0.130.110.5738961038961040.815]);
% Uncomment the following line to preserve the X-limits of the axes % xlim(axes1,[1960 2010]); % Uncomment the following line to preserve the Y-limits of the axes % ylim(axes1,[123 200]); hold(axes1,'all');
% Create multiple lines using matrix input to plot
plot1 = plot(X1,YMatrix1,'LineWidth',2);
set(plot1(1),'MarkerFaceColor',[000],'MarkerEdgeColor',[000],...
'Marker','o',...
'LineStyle','--',...
'Color',[0.50190.50190.5019]);
set(plot1(2),'Color',[100]);
% Create text text('Parent',axes1,'String','y=-0.3884*x+920','Position',[19651350],...
'Color',[100]);
% Create text text('Parent',axes1,'String','R²=0.3845','Position',[19651300],...
'Color',[100]);
Hallo,
Das Parent von dem Barchart ist das Handle der Axes,
Die Position musst du also über die Position der Axes bestimmen.
->2.Axes oben rechts in der Figure erzeugen
->Barchart hierrein plotten
->2.Axes unsichtbar machen, dann sieht man nur die Bars.
Ich habe deinen Code einfach etwas verändert, vll ist es das was du gesucht hast:
Code:
function createfigure(X1, YMatrix1, yvector1)
%CREATEFIGURE(X1,YMATRIX1,YVECTOR1,PARENT1) % X1: vector of x data % YMATRIX1: matrix of y data % YVECTOR1: bar yvector % PARENT1: bar parent
% Auto-generated by MATLAB on 11-Jan-2011 16:55:00
% Create axes
axes1 = axes('Parent',figure1,...
'Position',[0.130.110.7738961038961040.815]);
axes2= axes('Parent',figure1,'units','normalized','position',[0.650.650.250.25]);
% Uncomment the following line to preserve the X-limits of the axes % xlim(axes1,[1960 2010]); % Uncomment the following line to preserve the Y-limits of the axes % ylim(axes1,[123 200]);
% Create multiple lines using matrix input to plot
plot1 = plot(axes1,X1,YMatrix1,'LineWidth',2);
set(plot1(1),'MarkerFaceColor',[000],'MarkerEdgeColor',[000],...
'Marker','o',...
'LineStyle','--',...
'Color',[0.50190.50190.5019]);
set(plot1(2),'Color',[100]);
% Create text text('Parent',axes1,'String','y=-0.3884*x+920','Position',[19651350],...
'Color',[100]);
% Create text text('Parent',axes1,'String','R²=0.3845','Position',[19651300],...
'Color',[100]);
Du kannst Beiträge in dieses Forum schreiben. Du kannst auf Beiträge in diesem Forum antworten. Du kannst deine Beiträge in diesem Forum nicht bearbeiten. Du kannst deine Beiträge in diesem Forum nicht löschen. Du kannst an Umfragen in diesem Forum nicht mitmachen. Du kannst Dateien in diesem Forum posten Du kannst Dateien in diesem Forum herunterladen
MATLAB, Simulink, Stateflow, Handle Graphics, Real-Time Workshop, SimBiology, SimHydraulics, SimEvents, and xPC TargetBox are registered trademarks and The MathWorks, the L-shaped membrane logo, and Embedded MATLAB are trademarks of The MathWorks, Inc.