Thread Subject: subplots in a GUI

Subject: subplots in a GUI

From: Abel Brown

Date: 17 Apr, 2008 02:21:01

Message: 1 of 4

so i have two radio buttons

if radiobutton1 is selected then only one plot is produced

if radiobutton2 is selected then i want to do a subplot of 3
different plots

in the pushbutton_callback i have

axes(handles.axes1);
cla;

...

switch selection

    case 'SNR'

       plot(...)

    case 'CS'

       subplot(3,1,1)
       ...

       subplot(3,1,2)
       ...

       subplot(3,1,3)

end

the problem is that the GUI crashes when i do the subplots.

the subplot bulges way outside of the axes boundaries and on
top of all the buttons etc.

Is there some trick to going back and forth between plots
and subplots in a gui?

Thanks!

Subject: subplots in a GUI

From: ImageAnalyst

Date: 17 Apr, 2008 02:37:57

Message: 2 of 4

On Apr 16, 10:21=A0pm, "Abel Brown" <brown.2...@osu.edu> wrote:
> so i have two radio buttons
>
> if radiobutton1 is selected then only one plot is produced
>
> if radiobutton2 is selected then i want to do a subplot of 3
> different plots
>
> in the pushbutton_callback i have
>
> axes(handles.axes1);
> cla;
>
> ...
>
> switch selection
>
> =A0 =A0 case 'SNR'
>
> =A0 =A0 =A0 =A0plot(...)
>
> =A0 =A0 case 'CS'
>
> =A0 =A0 =A0 =A0subplot(3,1,1)
> =A0 =A0 =A0 =A0...
>
> =A0 =A0 =A0 =A0subplot(3,1,2)
> =A0 =A0 =A0 =A0...
>
> =A0 =A0 =A0 =A0subplot(3,1,3)
>
> end
>
> the problem is that the GUI crashes when i do the subplots.
>
> the subplot bulges way outside of the axes boundaries and on
> top of all the buttons etc.
>
> Is there some trick to going back and forth between plots
> and subplots in a gui?
>
> Thanks!
----------------------------------
Abel:
I don't know - I don't use subplot() in an axes (like one I placed on
a main window using GUIDE). I only use subplots for simple script
type m files. What I do (on complicated Guide-built GUI's) is to just
have separate axes. Can you do that, just have 4 axes and just plot
into the big one if you're using one and plot into the 3 smaller axes
if you're using all 3? (Hide - set visibility to 'off' - the plot(s)
that you're not using). In essence, plot what you want where you want
and just hide the other plots that you're not using.
Regards,
ImageAnalyst

Subject: subplots in a GUI

From: Ashwini Deshpande

Date: 17 Apr, 2008 05:34:02

Message: 3 of 4

"Abel Brown" <brown.2179@osu.edu> wrote in message
<fu6c6d$g9g$1@fred.mathworks.com>...
> so i have two radio buttons
>
> if radiobutton1 is selected then only one plot is produced
>
> if radiobutton2 is selected then i want to do a subplot of 3
> different plots
>
> in the pushbutton_callback i have
>
> axes(handles.axes1);
> cla;
>
> ...
>
> switch selection
>
> case 'SNR'
>
> plot(...)
>
> case 'CS'
>
> subplot(3,1,1)
> ...
>
> subplot(3,1,2)
> ...
>
> subplot(3,1,3)
>
> end
>
> the problem is that the GUI crashes when i do the subplots.
>
> the subplot bulges way outside of the axes boundaries and on
> top of all the buttons etc.
>
> Is there some trick to going back and forth between plots
> and subplots in a gui?
>
> Thanks!

Hai,
Try out the following, hope it will work.
As u insert radio buttons inside the Button Group Panel,
similarly insert the axes also in another Button Group Panel
 (only one axes, we need not seperate 3 axes).
Say ur radio Button Group Panel is tagged as radio_panel and
axes Button Group Panel as axes_panel. Then write the
following code in function:
radio_panel_SelectionChangeFcn(hObject, eventdata, handles)
h = get(handles.uipanel1,'SelectedObject');
s = get(h,'String');
t = 0:0.01:1;
x = sin(2*pi*3*t);
switch s
    case '1 PLOT'
        h = subplot(1,1,1,'Parent',handles.axes_panel);
        plot(h,x,'r');
    case '3 Sub PLOTs'
        h1 = subplot(3,1,1,'Parent',handles.axes_panel);
        plot(h1,x,'r');
        h2 = subplot(3,1,2,'Parent',handles.axes_panel);
        plot(h2,2*x,'b');
        h3 = subplot(3,1,3,'Parent',handles.axes_panel);
        plot(h3,3*x,'g');
    otherwise
end

If this is not clear, plz let me know so that i can mail u
the sample program which i have already with me.

Regards,
Ashwini

Subject: subplots in a GUI

From: Abel Brown

Date: 17 Apr, 2008 12:53:02

Message: 4 of 4

wow, thanks! You guys are great!!!

Got it working!

Thanks again!

Tags for this Thread

Everyone's Tags:

Add a New Tag:

Separated by commas
Ex.: root locus, bode

What are tags?

A tag is like a keyword or category label associated with each thread. Tags make it easier for you to find threads of interest.

Anyone can tag a thread. Tags are public and visible to everyone.

Tag Activity for This Thread
Tag Applied By Date/Time
gui subplots axes Abel Brown 16 Apr, 2008 22:25:05
rssFeed for this Thread

Contact us at files@mathworks.com