Path: news.mathworks.com!not-for-mail
From: <HIDDEN>
Newsgroups: comp.soft-sys.matlab
Subject: Select data to plot using checkboxes
Date: Sat, 22 Nov 2008 19:58:01 +0000 (UTC)
Organization: Aalborg Universitet
Lines: 15
Message-ID: <gg9o89$8tj$1@fred.mathworks.com>
Reply-To: <HIDDEN>
NNTP-Posting-Host: webapp-02-blr.mathworks.com
Content-Type: text/plain; charset="ISO-8859-1"
Content-Transfer-Encoding: 8bit
X-Trace: fred.mathworks.com 1227383881 9139 172.30.248.37 (22 Nov 2008 19:58:01 GMT)
X-Complaints-To: news@mathworks.com
NNTP-Posting-Date: Sat, 22 Nov 2008 19:58:01 +0000 (UTC)
X-Newsreader: MATLAB Central Newsreader 1567325
Xref: news.mathworks.com comp.soft-sys.matlab:502523


Hi
I'm making a GUI, where I have four checkboxes each representing a dataset (data1, data2, data3, data4). I would like to be able to plot one or multiple dataset on the same axes depending on whether the checkbox is selected or not, i.e. the value of the checkbox is 0 (not selected) or 1 (selected). For example if value of checkbox1 is 1, data1 is plotted and if value of checkbox1 is 0, the data1 is removed from the axes / not plotted.

I've tried to make an if-construction in the callback function for each checkbox:
if get(checkbox1, value) ==1
plot(data1)
hold on
elseif get(checkbox, value) == 0
hold off

And that means that I can select and plot multiple data, i.e. when checkbox1 and checkbox2 is selected, data1 and data2 is plotted on the same axes. But when checkbox1 is deselected, the graph for data1 is not removed.
Any ideas or suggestions to do that?

Thanks in advance.
/Linda