Matlab GUI axis buttondownfnc Select points
1 view (last 30 days)
Show older comments
I've got a figure with different points that are related in pairs. When clicking in one of the points I would like to change the marker of that point and also the marker of the related point.
Then when clinking in the axis instead of a point return the markers to its original.
0 Comments
Accepted Answer
Patrick Kalita
on 15 Jul 2011
Well this sounded like a fun one, so here's what I came up with:
% Set up my data sets. Each pair of x-coordinates goes into one column of a
% 2-by-N array. Each pair of y-coordinates goes into one column of another 2-by-N
% array.
X = [ rand(1,10); rand(1,10) ];
Y = [ rand(1,10); rand(1,10) ];
% Make an axes and plot the lines. When you give PLOT two arrays like this it
% will make a separate line for each column of data.
a = axes;
p = plot(a, X, Y, 'LineStyle', 'none', 'Marker', 'o', 'MarkerSize', 15, 'Color', 'k');
% When you click on the axes, set all of the marker of all the lines.
set(a, 'ButtonDownFcn', @(src, evt) set( p, 'Marker', 'o' ) );
% When you click on a line, set the marker of just the line you clicked on.
set(p, 'ButtonDownFcn', @(src, evt) set( src, 'Marker', 's' ) );
2 Comments
Walter Roberson
on 15 Jul 2011
Not easily, no. You would have to plot the line with no markers at all, and then plot each point with the marker appropriate for it.
The "line" and "lineseries" objects are restricted to one marker type per line.
More Answers (1)
See Also
Categories
Find more on Lighting, Transparency, and Shading in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!