Make the MATLAB click a plot graph a subgraph

In Matlab 2011b, I have a multidimensional matrix, which should be initially presented as a 2D graph of its two sizes. I want the markers to be left clickable. Clicking on the marker draws a new shape of other sizes, cut by click.

This question is related to Matlab: specify the points and make them available to display information about it , but I want to run a script, and not just pop-up data about the clicked point.

Googling hinted that it ButtonDownFcncould be used, but the examples I found require manually building each point and attaching a handler, for example:

hp = plot(x(1), y(1), 'o');
set(hp, 'buttondownfcn', 'disp(1)');

Since there are many markers on the main chart, is it possible to simply attach a handler to the entire curve and call the function of constructing a subgraph with an index (preferably) or coordinates of the marker click?

+3
source share
1 answer

this is an idea of ​​what you need and should help you get started if I understand your requirements.

In this case, when you select a curve, it will draw it in the lower subtitle, keeping the color.

function main
subplot(211)
h = plot (peaks);

set (h,'buttondownfcn', @hitme)
end

function hitme(gcbo,evendata)
subplot (212)
hold on;

col = get (gcbo,'Color');
h2 =  plot (get (gcbo,'XData'),get (gcbo,'YData'));
set (h2,'Color', col)

pt = get (gca, 'CurrentPoint');
disp (pt);
end

You can explore your options just to write get(gcbo)in functions hitme.

+3
source

All Articles