Dynamically plot graphs to axes component

Is it possible to dynamically add a number of "axes components" onto a GUIDE fig. I want to display a graph of data for each file in a directory. But this number can vary. Sometimes 2, sometimes 6. Thanks

Antworten (2)

Paulo Silva
Paulo Silva am 11 Mai 2011

0 Stimmen

To remove all the subplots from your GUI do this:
delete(findall(gcf,'type','axes'))

3 Kommentare

Jason
Jason am 12 Mai 2011
Hi, I dont want to remove all axes, just add a number depending on the number of files that are selected.
Walter Roberson
Walter Roberson am 12 Mai 2011
Is there a fixed total size in which all the plots are to go? If so then subplot() . Or is the figure to grow to fit the plots? If so, what if you run out of screen? Is a new figure to be created for each plot? Or do you want to use fixed size per plot but have the area scrollable to see the other plots?
Jason
Jason am 12 Mai 2011
Yes there is, the size of my form I use in GUIDE. Yes a fixed size per plot with screen scrolling is desirable.

Melden Sie sich an, um zu kommentieren.

Patrick Kalita
Patrick Kalita am 12 Mai 2011

0 Stimmen

You can use the axes command. You'll probably want to set the 'Position' property, and store the handle to the axes in the handles structure.
handles.axes1 = axes('Position', [x1 y1 w1 h1]);
handles.axes2 = axes('Position', [x2 y2 w2 h2]);
...
When you need to remove an axes from the GUI, you should pass the axes handle to the delete function:
delete(handles.axes1);

2 Kommentare

Jason
Jason am 12 Mai 2011
how can I have handles.axesi where i is a variable? This depends on the number of file sin the directory which can change.
Patrick Kalita
Patrick Kalita am 12 Mai 2011
You could also store all the axes handles together in a cell array as one field in the handles structure:
handles.axes{1} = axes( ... );
handles.axes{2} = axes( ... );

Melden Sie sich an, um zu kommentieren.

Kategorien

Mehr zu Creating, Deleting, and Querying Graphics Objects finden Sie in Hilfe-Center und File Exchange

Gefragt:

am 11 Mai 2011

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by