WICHTIG: Der Betrieb von goMatlab.de wird privat finanziert fortgesetzt. - Mehr Infos...

Mein MATLAB Forum - goMatlab.de

Mein MATLAB Forum

 
Gast > Registrieren       Autologin?   

Partner:




Forum
      Option
[Erweitert]
  • Diese Seite per Mail weiterempfehlen
     


Gehe zu:  
Neues Thema eröffnen Neue Antwort erstellen

Problem mit Parent bei createfigure

 

nadja

Gast


Beiträge: ---
Anmeldedatum: ---
Wohnort: ---
Version: ---
     Beitrag Verfasst am: 12.01.2011, 10:38     Titel: Problem mit Parent bei createfigure
  Antworten mit Zitat      
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 figure
figure1 = figure;

% Create axes
axes1 = axes('Parent',figure1,...
    'Position',[0.13 0.11 0.573896103896104 0.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',[0 0 0],'MarkerEdgeColor',[0 0 0],...
    'Marker','o',...
    'LineStyle','--',...
    'Color',[0.5019 0.5019 0.5019]);
set(plot1(2),'Color',[1 0 0]);

% Create text
text('Parent',axes1,'String','y=-0.3884*x+920','Position',[1965 135 0],...
    'Color',[1 0 0]);

% Create text
text('Parent',axes1,'String','R²=0.3845','Position',[1965 130 0],...
    'Color',[1 0 0]);

% Create ylabel
ylabel('Observed flowering (yearday)');

% Create title
title('Phenology change during 3 decades for Sambucus nigra');

% Create bar
bar(yvector1,'FaceColor',[0.701960802078247 0.780392169952393 1],...
    'Parent',Parent1);

% Create textbox
annotation(figure1,'textbox',...
    [0.418149478563152 0.863636363636363 0.0499849362688297 0.0430622009569359],...
    'String',{'-2,3'},...
    'FitBoxToText','off',...
    'LineStyle','none');

% Create textbox
annotation(figure1,'textbox',...
    [0.523595596755504 0.799043062200956 0.0465086906141367 0.0550239234449739],...
    'String',{'-4,4'},...
    'FitBoxToText','off',...
    'LineStyle','none');

% Create textbox
annotation(figure1,'textbox',...
    [0.623247972190035 0.760765550239234 0.0511436848203939 0.0358851674641146],...
    'String',{'-6,3'},...
    'FitBoxToText','off',...
    'LineStyle','none');


Gast

Gast


Beiträge: ---
Anmeldedatum: ---
Wohnort: ---
Version: ---
     Beitrag Verfasst am: 12.01.2011, 11:14     Titel:
  Antworten mit Zitat      
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 figure
figure1 = figure;

% Create axes
axes1 = axes('Parent',figure1,...
    'Position',[0.13 0.11 0.773896103896104 0.815]);
axes2= axes('Parent',figure1,'units','normalized','position',[0.65 0.65 0.25 0.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',[0 0 0],'MarkerEdgeColor',[0 0 0],...
    'Marker','o',...
    'LineStyle','--',...
    'Color',[0.5019 0.5019 0.5019]);
set(plot1(2),'Color',[1 0 0]);

% Create text
text('Parent',axes1,'String','y=-0.3884*x+920','Position',[1965 135 0],...
    'Color',[1 0 0]);

% Create text
text('Parent',axes1,'String','R²=0.3845','Position',[1965 130 0],...
    'Color',[1 0 0]);

% Create ylabel
ylabel('Observed flowering (yearday)');

% Create title
title('Phenology change during 3 decades for Sambucus nigra');

% Create bar
bar(yvector1,'FaceColor',[0.701960802078247 0.780392169952393 1],...
    'Parent',axes2);
set(axes2,'visible','off');
% Create textbox
annotation(figure1,'textbox',...
    [0.418149478563152 0.863636363636363 0.0499849362688297 0.0430622009569359],...
    'String',{'-2,3'},...
    'FitBoxToText','off',...
    'LineStyle','none');

% Create textbox
annotation(figure1,'textbox',...
    [0.523595596755504 0.799043062200956 0.0465086906141367 0.0550239234449739],...
    'String',{'-4,4'},...
    'FitBoxToText','off',...
    'LineStyle','none');

% Create textbox
annotation(figure1,'textbox',...
    [0.623247972190035 0.760765550239234 0.0511436848203939 0.0358851674641146],...
    'String',{'-6,3'},...
    'FitBoxToText','off',...
    'LineStyle','none');
 
 
nadja

Gast


Beiträge: ---
Anmeldedatum: ---
Wohnort: ---
Version: ---
     Beitrag Verfasst am: 12.01.2011, 11:26     Titel:
  Antworten mit Zitat      
Das hat funktioniert, vielen Dank! Smile
 
Neues Thema eröffnen Neue Antwort erstellen



Einstellungen und Berechtigungen
Beiträge der letzten Zeit anzeigen:

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
.





 Impressum  | Nutzungsbedingungen  | Datenschutz | FAQ | goMatlab RSS Button RSS

Hosted by:


Copyright © 2007 - 2025 goMatlab.de | Dies ist keine offizielle Website der Firma The Mathworks

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.