Interactive Plot: click and display updated trace?
Mostrar comentarios más antiguos
Dear all,
I have a 3D matrix (in this example is "Data") and what I would like to do is:
- Plot the first slice
- Click on a specific point of the 2D-plot
- Get in another figure the behaviour of the point selected across the 3D matrix.
Now, the exapmple attached is doing exactly what I want.
However, is it possible to keep clicking on the figure and update the plot on the second figure without re-running the code every time?
Here the example:
clc
Size = rand(10,10,20);
Ax = linspace(1,10,10);
%
figure(1)
subplot 121
imagesc(Ax, Ax, Size(:, :, 1));
axis square xy
%
[xm, ym] = ginput(1); %xmouse, ymouse
[~, xidx] = min(abs(Ax-xm)); %closest index
[~, yidx] = min(abs(Ax-ym));
hold on
plot(Ax(xidx), Ax(yidx), 'rx')
%
trace = zeros(1, size(Size, 3));
for t2s = 1 : size(Size, 3)
trace(t2s) = Size(xidx, yidx, t2s);
end
subplot 122
plot(1:size(Size, 3), trace)
axis square xy
I saw that there might be some callback functions that can be used? I am using the ginput option..
Thanks for help!
Best,
E
Respuesta aceptada
Más respuestas (0)
Categorías
Más información sobre Data Exploration en Centro de ayuda y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!