Plot to highlight selected data

3 Ansichten (letzte 30 Tage)
Lauren Dransfield
Lauren Dransfield am 31 Jan. 2014
I'd like to create something similar to this . The differences are: my table only has one column, which is the variable I changed to get my data. I have the table set up and working, and most of what I have works, but I only seem to be able to highlight one thing at once. This is what I have:
% Set up plots etc
for a = 1:length(data);
xAxis = data{a,1}(:,X);
yAxis = data{a,1}(:,Y);
plot(graph,xAxis,yAxis);
% Visible data
hilite = plot(graph,xAxis,yAxis,'o-','LineWidth',2,'HandleVisibility','off','Visible','off');
% Invisible data, to be highlighted later
hold all
end
hold off
% Data table callback function
function dataTable_Callback(hObject, eventdata)
set(hilite,'Visible','off')
names = get(hObject,'Data');
select = eventdata.Indices(:,1);
for d = 1:length(select)
group = select(d);
xAxis = [];
% makes sure that previously selected data is removed
yAxis = [];
xAxis(:,d) = data{group,1}(:,X);
% if I remove the semicolon and let MATLAB print this data, I always get
the correct data in the correct columns, adding and subtracting them when
I select them
yAxis(:,d) = data{group,1}(:,Y);
set(hilite,'Visible','on','XData',xAxis(:,d),'YData',yAxis(:,d))
legend(hilite, num2str(names{select,1}(1,1)));
end
end
I've been playing with this for a few hours now, and I really can't work out what my issue is. Any help is obviously much appreciated! :-)

Antworten (0)

Kategorien

Mehr zu 2-D and 3-D Plots finden Sie in Help Center und File Exchange

Produkte

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by