Thread Subject: GUI - plotyy and legends depending on selected checkboxes

Subject: GUI - plotyy and legends depending on selected checkboxes

From: Linda

Date: 2 Dec, 2008 18:54:02

Message: 1 of 1

Hi
I’ve made a GUI, where I have two radiobuttons representing a category of data. If one of these radiobuttons is selected (only one can be selected at a time), some checkboxes will be showed. These checkboxes each represent dataset (data1, data2, data3, data4). With help from some of you I’m now able to plot the different dataset on the same axes depending on which checkboxes are selected.

This means that when radiobutton1 is selected, four different plots can be made, and the same is the case for radiobutton2
I have two questions:
- I’ve tried to make legends to represent each dataset in the same way like the plots below are defined, but can only show one at a time. How do I show several legends in one plot?

- The dataset connected with radiobutton2 have two different units, i.e. dataset1_rb2 and dataset2_rb2 have the same unit, while dataset3_rb2 and dataset4_rb2 have another unit. Therefore I would like to be able to make two y-axes. But the problem is that the dataset connected to radiobutton1 has a third unit. So I need to make one set of axes for radiobutton1 and another set for radiobutton2 (with two different y-axes).
I’ve tried using plotyy for only radiobutton2, but the result is that if I first select radiobutton2 (and plot something) before selecting radiobutton1, nothing is plotted.

Thank you for reading this. Hope you can give me some ideas of how to do it.
/Linda

I’ve made an Update pushbutton with the callback:

%Previous plot is set to visible off
set(findobj('tag','dataset1_rb1'),'Visible','off');
set(findobj('tag','dataset2_rb1'),'Visible','off');

set(findobj('tag','dataset1_rb2'),'Visible','off');
set(findobj('tag','dataset2_rb2'),'Visible','off');
etc. …

%For radiobutton1
if get(radiobutton1,'Value') == 1

   plotDataset1_rb1 = plot(xdata1_rb1, ydata1_rb1,'bx-');
   hold on;
 
    set(plotDataset1_rb1, 'tag','dataset1_rb1','Visible','off');
    stateData1_rb1 = {'off','on'};
    defineStateData1_rb1 = stateData1_rb1{1+get(checkbox1_rb1, 'Value')};
    set(findobj('tag','dataset1_rb1'),'Visible',defineStateData1_rb1);


   plotDataset2_rb1 = plot(xdata2_rb1, ydata2_rb1,'gx-');
   hold on;
 
    set(plotDataset2_rb1, 'tag','dataset2_rb1','Visible','off');
    stateData2_rb1 = {'off','on'};
    defineStateData2_rb1 = stateData2_rb1{1+get(checkbox2_rb1, 'Value')};
    set(findobj('tag','dataset2_rb1'),'Visible',defineStateData2_rb1);

etc. …
end

%For radiobutton2
if get(radiobutton2,'Value') == 1

if get(checkbox1_rb2,'Value') == 1 || get(checkbox2_rb2,'Value') == 1

plotDataset1_rb2 = stairs(xdata1_rb2,ydata1_rb2,'b-');
hold on;
 
set(plotDataset1_rb2, 'tag','dataset1_rb2','Visible','off');
stateData1_rb2 = {'off','on'};
defineStateData1_rb2 = stateData1_rb2{1+get(checkbox1_rb2, 'Value')};
set(findobj('tag','dataset1_rb2'),'Visible',defineState1_rb2);

plotDataset2_rb2 = stairs(xdata2_rb2,ydata2_rb2,'r-');
hold on;
 
set(plotDataset2_rb2, 'tag','dataset2_rb2','Visible','off');
stateData2_rb2 = {'off','on'};
defineStateData2_rb2 = stateData2_rb2{1+get(checkbox2_rb2, 'Value')};
set(findobj('tag','dataset2_rb2'),'Visible',defineState2_rb2);

end

if get(checkbox3_rb2,'Value') == 1 || get(checkbox4_rb2,'Value') == 1

plotDataset3_rb2 = line(xdata3_rb2,ydata3_rb2, 'Color', 'm');
hold on;
 
set(plotDataset3_rb2, 'tag','dataset3_rb2','Visible','off');
stateData3_rb2 = {'off','on'};
defineStateData3_rb2 = stateData3_rb2{1+get(checkbox3_rb2, 'Value')};
set(findobj('tag','dataset3_rb2'),'Visible',defineState3_rb2);

plotDataset4_rb2 = line(xdata4_rb2,ydata4_rb2, 'Color', 'y');
hold on;
 
set(plotDataset4_rb2, 'tag','dataset4_rb2','Visible','off');
stateData4_rb2 = {'off','on'};
defineStateData4_rb2 = stateData4_rb2{1+get(checkbox4_rb2, 'Value')};
set(findobj('tag','dataset4_rb2'),'Visible',defineState4_rb2);

end

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
legends Linda 2 Dec, 2008 13:55:06
plotyy Linda 2 Dec, 2008 13:55:05
checkboxes Linda 2 Dec, 2008 13:55:05
gui Linda 2 Dec, 2008 13:55:05
rssFeed for this Thread
 

MATLAB Central Terms of Use

NOTICE: Any content you submit to MATLAB Central, including personal information, is not subject to the protections which may be afforded information collected under other sections of The MathWorks, Inc. Web site. You are entirely responsible for all content that you upload, post, e-mail, transmit or otherwise make available via MATLAB Central. The MathWorks does not control the content posted by visitors to MATLAB Central and, does not guarantee the accuracy, integrity, or quality of such content. Under no circumstances will The MathWorks be liable in any way for any content not authored by The MathWorks, or any loss or damage of any kind incurred as a result of the use of any content posted, e-mailed, transmitted or otherwise made available via MATLAB Central. Read the complete Terms prior to use.

Contact us at files@mathworks.com