http://www.mathworks.com/matlabcentral/newsreader/view_thread/239359
MATLAB Central Newsreader  How can I plot multiple graphs on the same single plot using GUI?
Feed for thread: How can I plot multiple graphs on the same single plot using GUI?
enus
©19942014 by MathWorks, Inc.
webmaster@mathworks.com
MATLAB Central Newsreader
http://blogs.law.harvard.edu/tech/rss
60
MathWorks
http://www.mathworks.com/images/membrane_icon.gif

Mon, 17 Nov 2008 14:32:01 +0000
How can I plot multiple graphs on the same single plot using GUI?
http://www.mathworks.com/matlabcentral/newsreader/view_thread/239359#611281
Bernard Lee
I have three radio buttons, each plots a single graph. <br>
for eg. 1st radio button > a V graph<br>
2nd radio button > a D graph<br>
3rd radio button > a S graph <br>
How can I plot multiple graphs on the same single plot using GUI?<br>
for eg. if i select the 1st and 3rd radio button, i will get the V and S graphs on the <br>
same plot<br>
if i select the 2nd and 3rd radio button, i will get the D and S graphs on the <br>
same plot.<br>
<br>
Can you help me with ideas to create such radiobuttons as well as display using plot command. thanks alot.

Mon, 17 Nov 2008 14:50:19 +0000
Re: How can I plot multiple graphs on the same single plot using GUI?
http://www.mathworks.com/matlabcentral/newsreader/view_thread/239359#611289
Johan Carlson
"Bernard Lee" <leeshijun@gmail.com> wrote in message <gfrv91$cep$1@fred.mathworks.com>...<br>
> I have three radio buttons, each plots a single graph. <br>
> for eg. 1st radio button > a V graph<br>
> 2nd radio button > a D graph<br>
> 3rd radio button > a S graph <br>
> How can I plot multiple graphs on the same single plot using GUI?<br>
> for eg. if i select the 1st and 3rd radio button, i will get the V and S graphs on the <br>
> same plot<br>
> if i select the 2nd and 3rd radio button, i will get the D and S graphs on the <br>
> same plot.<br>
> <br>
> Can you help me with ideas to create such radiobuttons as well as display using plot command. thanks alot.<br>
<br>
Hi,<br>
<br>
What you need to do is to get a handle to the axes of your plot. For example, when you create the first plot (or the axes) you can set the 'Tag' property, by writing<br>
<br>
set(gca,'Tag','myplotaxes');<br>
<br>
Then, in the callback of your radio buttons, do something like:<br>
<br>
axes(findobj('Tag','myplotaxes'));<br>
hold on;<br>
plot(....)<br>
<br>
If I understand your problem correctly, something like this should do the trick...<br>
<br>
/JC

Mon, 17 Nov 2008 14:52:59 +0000
Re: How can I plot multiple graphs on the same single plot using
http://www.mathworks.com/matlabcentral/newsreader/view_thread/239359#611292
Venky
<as well as display using plot command. thanks alot.><br>
<br>
you can use Hold On and Hold Off commands in addition with Plot(), to plot the graphs in the same window

Mon, 17 Nov 2008 15:26:02 +0000
Re: How can I plot multiple graphs on the same single plot using GUI?
http://www.mathworks.com/matlabcentral/newsreader/view_thread/239359#611295
Bernard Lee
"Johan Carlson" <Johan.E.Carlson@gmail.com> wrote in message <gfs0bb$quv$1@fred.mathworks.com>...<br>
> "Bernard Lee" <leeshijun@gmail.com> wrote in message <gfrv91$cep$1@fred.mathworks.com>...<br>
> > I have three radio buttons, each plots a single graph. <br>
> > for eg. 1st radio button > a V graph<br>
> > 2nd radio button > a D graph<br>
> > 3rd radio button > a S graph <br>
> > How can I plot multiple graphs on the same single plot using GUI?<br>
> > for eg. if i select the 1st and 3rd radio button, i will get the V and S graphs on the <br>
> > same plot<br>
> > if i select the 2nd and 3rd radio button, i will get the D and S graphs on the <br>
> > same plot.<br>
> > <br>
> > Can you help me with ideas to create such radiobuttons as well as display using plot command. thanks alot.<br>
> <br>
> Hi,<br>
> <br>
> What you need to do is to get a handle to the axes of your plot. For example, when you create the first plot (or the axes) you can set the 'Tag' property, by writing<br>
> <br>
> set(gca,'Tag','myplotaxes');<br>
> <br>
> Then, in the callback of your radio buttons, do something like:<br>
> <br>
> axes(findobj('Tag','myplotaxes'));<br>
> hold on;<br>
> plot(....)<br>
> <br>
> If I understand your problem correctly, something like this should do the trick...<br>
> <br>
> /JC<br>
<br>
Hi JC,<br>
<br>
thanks alot. Sorry I forgot to mention that I have actually 8 radio buttons, meaning 8 graphs in all. does what you say earlier still applies? I wrote 3 radio buttons because I wanted to simplify the problem..

Tue, 18 Nov 2008 02:18:04 +0000
Re: How can I plot multiple graphs on the same single plot using GUI?
http://www.mathworks.com/matlabcentral/newsreader/view_thread/239359#611407
Paul Mennen
> thanks alot. Sorry I forgot to mention that I have actually 8 radio buttons,<br>
> meaning 8 graphs in all. does what you say earlier still applies?<br>
<br>
Another solution you may want to try is to use "plt" (available on the<br>
file exchange) instead of "plot" which was designed especially for the<br>
situation when many traces are needed. It doesn't use radio buttons are<br>
you are suggesting, but it uses almost the same idea by using the trace ID<br>
labels as a sort of radio button. You simply click on the trace ID label to<br>
toggle a trace on or off. (The trace ID changes in an obvious way so you<br>
know if it is on or off.)<br>
<br>
I would first try "plt5.m", in the demo folder  the simplest example of<br>
how to use plt. Note that 5 traces are plotted on a single graph and you<br>
can easily use the mouse to select which traces are on or off. plt also has<br>
all the capabilities of plotyy, plotyyy, ect. Extensive documentation on plt<br>
is available in the plt.chm help file.<br>
<br>
~Paul

Tue, 18 Nov 2008 12:09:02 +0000
Re: How can I plot multiple graphs on the same single plot using GUI?
http://www.mathworks.com/matlabcentral/newsreader/view_thread/239359#611470
Bernard Lee
"Johan Carlson" <Johan.E.Carlson@gmail.com> wrote in message <gfs0bb$quv$1@fred.mathworks.com>...<br>
> "Bernard Lee" <leeshijun@gmail.com> wrote in message <gfrv91$cep$1@fred.mathworks.com>...<br>
> > I have three radio buttons, each plots a single graph. <br>
> > for eg. 1st radio button > a V graph<br>
> > 2nd radio button > a D graph<br>
> > 3rd radio button > a S graph <br>
> > How can I plot multiple graphs on the same single plot using GUI?<br>
> > for eg. if i select the 1st and 3rd radio button, i will get the V and S graphs on the <br>
> > same plot<br>
> > if i select the 2nd and 3rd radio button, i will get the D and S graphs on the <br>
> > same plot.<br>
> > <br>
> > Can you help me with ideas to create such radiobuttons as well as display using plot command. thanks alot.<br>
> <br>
> Hi,<br>
> <br>
> What you need to do is to get a handle to the axes of your plot. For example, when you create the first plot (or the axes) you can set the 'Tag' property, by writing<br>
> <br>
> set(gca,'Tag','myplotaxes');<br>
> <br>
> Then, in the callback of your radio buttons, do something like:<br>
> <br>
> axes(findobj('Tag','myplotaxes'));<br>
> hold on;<br>
> plot(....)<br>
> <br>
> If I understand your problem correctly, something like this should do the trick...<br>
> <br>
> /JC<br>
<br>
Hi JC, <br>
<br>
Your method solved my problem...but now i dont know how to update the legend of the graph.

Tue, 18 Nov 2008 14:22:01 +0000
Re: How can I plot multiple graphs on the same single plot using GUI?
http://www.mathworks.com/matlabcentral/newsreader/view_thread/239359#611500
Johan Carlson
"Bernard Lee" <leeshijun@gmail.com> wrote in message <gfub8t$b2r$1@fred.mathworks.com>...<br>
> "Johan Carlson" <Johan.E.Carlson@gmail.com> wrote in message <gfs0bb$quv$1@fred.mathworks.com>...<br>
> > "Bernard Lee" <leeshijun@gmail.com> wrote in message <gfrv91$cep$1@fred.mathworks.com>...<br>
> > > I have three radio buttons, each plots a single graph. <br>
> > > for eg. 1st radio button > a V graph<br>
> > > 2nd radio button > a D graph<br>
> > > 3rd radio button > a S graph <br>
> > > How can I plot multiple graphs on the same single plot using GUI?<br>
> > > for eg. if i select the 1st and 3rd radio button, i will get the V and S graphs on the <br>
> > > same plot<br>
> > > if i select the 2nd and 3rd radio button, i will get the D and S graphs on the <br>
> > > same plot.<br>
> > > <br>
> > > Can you help me with ideas to create such radiobuttons as well as display using plot command. thanks alot.<br>
> > <br>
> > Hi,<br>
> > <br>
> > What you need to do is to get a handle to the axes of your plot. For example, when you create the first plot (or the axes) you can set the 'Tag' property, by writing<br>
> > <br>
> > set(gca,'Tag','myplotaxes');<br>
> > <br>
> > Then, in the callback of your radio buttons, do something like:<br>
> > <br>
> > axes(findobj('Tag','myplotaxes'));<br>
> > hold on;<br>
> > plot(....)<br>
> > <br>
> > If I understand your problem correctly, something like this should do the trick...<br>
> > <br>
> > /JC<br>
> <br>
> Hi JC, <br>
> <br>
> Your method solved my problem...but now i dont know how to update the legend of the graph.<br>
<br>
<br>
I guess you could use a similar trick, i.e. keeping track of the legend object by doing something like:<br>
<br>
h = legend(....)<br>
set(h,'tag','mylegend');<br>
<br>
Then each time you update the plot you can check if the legend exists, by<br>
if ~isempty(findobj('tag','mylegend'),<br>
delete(findobj('tag','mylegend');<br>
... and then draw a new legend in the same way as above.<br>
end<br>
<br>
Haven't tried it, but something like this should do it.<br>
<br>
/JC

Tue, 18 Nov 2008 16:19:02 +0000
Re: How can I plot multiple graphs on the same single plot using GUI?
http://www.mathworks.com/matlabcentral/newsreader/view_thread/239359#611544
Bernard Lee
"Johan Carlson" <Johan.E.Carlson@gmail.com> wrote in message <gfs0bb$quv$1@fred.mathworks.com>...<br>
> "Bernard Lee" <leeshijun@gmail.com> wrote in message <gfrv91$cep$1@fred.mathworks.com>...<br>
> > I have three radio buttons, each plots a single graph. <br>
> > for eg. 1st radio button > a V graph<br>
> > 2nd radio button > a D graph<br>
> > 3rd radio button > a S graph <br>
> > How can I plot multiple graphs on the same single plot using GUI?<br>
> > for eg. if i select the 1st and 3rd radio button, i will get the V and S graphs on the <br>
> > same plot<br>
> > if i select the 2nd and 3rd radio button, i will get the D and S graphs on the <br>
> > same plot.<br>
> > <br>
> > Can you help me with ideas to create such radiobuttons as well as display using plot command. thanks alot.<br>
> <br>
> Hi,<br>
> <br>
> What you need to do is to get a handle to the axes of your plot. For example, when you create the first plot (or the axes) you can set the 'Tag' property, by writing<br>
> <br>
> set(gca,'Tag','myplotaxes');<br>
> <br>
> Then, in the callback of your radio buttons, do something like:<br>
> <br>
> axes(findobj('Tag','myplotaxes'));<br>
> hold on;<br>
> plot(....)<br>
> <br>
> If I understand your problem correctly, something like this should do the trick...<br>
> <br>
> /JC<br>
<br>
Hi JC, <br>
<br>
Your method solved my problem...but now i dont know how to update the legend of the graph.

Tue, 18 Nov 2008 18:00:20 +0000
Re: How can I plot multiple graphs on the same single plot using GUI?
http://www.mathworks.com/matlabcentral/newsreader/view_thread/239359#611582
Adam
"Bernard Lee" <leeshijun@gmail.com> wrote <br>
<br>
> Your method solved my problem...but now i dont know how to update the legend of the graph.<br>
<br>
What do you want to update? Just the names?<br>
<br>
legendString = {'one', 'two'};<br>
<br>
hL = legend(legendString);<br>
<br>
Now if you modify legendString you can update the legend<br>
<br>
legendString{1} = 'three';<br>
set(hL, 'String', legendString)<br>
<br>
Sorry if this doesn't answer your question (I didn't read everything because I would approach the problem differently)<br>
<br>
~Adam

Tue, 18 Nov 2008 18:43:02 +0000
Re: How can I plot multiple graphs on the same single plot using GUI?
http://www.mathworks.com/matlabcentral/newsreader/view_thread/239359#611609
Johan Carlson
"Adam" <not.real@email.com> wrote in message <gfuvrk$4l4$1@fred.mathworks.com>...<br>
> "Bernard Lee" <leeshijun@gmail.com> wrote <br>
> <br>
> > Your method solved my problem...but now i dont know how to update the legend of the graph.<br>
> <br>
> What do you want to update? Just the names?<br>
> <br>
> legendString = {'one', 'two'};<br>
> <br>
> hL = legend(legendString);<br>
> <br>
> Now if you modify legendString you can update the legend<br>
> <br>
> legendString{1} = 'three';<br>
> set(hL, 'String', legendString)<br>
> <br>
> Sorry if this doesn't answer your question (I didn't read everything because I would approach the problem differently)<br>
> <br>
> ~Adam<br>
<br>
<br>
<br>
I accidentally posted a reply higher up in this thread... Didn't know that was possible. Anyway, I answered the legend question there as well.<br>
<br>
Sorry about double postings...<br>
<br>
/JC

Thu, 20 Nov 2008 08:57:02 +0000
Re: How can I plot multiple graphs on the same single plot using GUI?
http://www.mathworks.com/matlabcentral/newsreader/view_thread/239359#612033
Bernard Lee
"Johan Carlson" <Johan.E.Carlson@gmail.com> wrote in message <gfv2bm$58o$1@fred.mathworks.com>...<br>
> "Adam" <not.real@email.com> wrote in message <gfuvrk$4l4$1@fred.mathworks.com>...<br>
> > "Bernard Lee" <leeshijun@gmail.com> wrote <br>
> > <br>
> > > Your method solved my problem...but now i dont know how to update the legend of the graph.<br>
> > <br>
> > What do you want to update? Just the names?<br>
> > <br>
> > legendString = {'one', 'two'};<br>
> > <br>
> > hL = legend(legendString);<br>
> > <br>
> > Now if you modify legendString you can update the legend<br>
> > <br>
> > legendString{1} = 'three';<br>
> > set(hL, 'String', legendString)<br>
> > <br>
> > Sorry if this doesn't answer your question (I didn't read everything because I would approach the problem differently)<br>
> > <br>
> > ~Adam<br>
> <br>
> <br>
> <br>
> I accidentally posted a reply higher up in this thread... Didn't know that was possible. Anyway, I answered the legend question there as well.<br>
> <br>
> Sorry about double postings...<br>
> <br>
> /JC<br>
<br>
Thanks alot to all who helped...my program is working..appreciate it!!!