Matlab GUI axis buttondownfnc Select points
2 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
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 comentarios
Respuesta aceptada
Patrick Kalita
el 15 de Jul. de 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 comentarios
Walter Roberson
el 15 de Jul. de 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.
Más respuestas (1)
Ver también
Categorías
Más información sobre Graphics Object Programming en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!