|
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
|