How to draw a figure with subplots which can pop up in a new window when I click at them?

10 visualizaciones (últimos 30 días)
Hi,all. How can we draw such a figure in which if you click at a subplot of the figure, that subplot will get enlarged and pop up in new figure window? What function shall be employed? Suppose we had a figure with 12 subplots, and if you click at any of the subplots, that subplots will be magnified and pop up in a new window. How can we make that? Thank you!

Respuesta aceptada

emehmetcik
emehmetcik el 15 de Feb. de 2015
Hi,
A simple way to do this is to use the button press callback function (ButtonDownFcn):
Here is an example:
clear
close all
clc
x1 = 1 : 10;
y1 = randn(1, 10);
x2 = randn(10);
y2 = randn(10);
figure;
h1 = subplot(2, 1, 1);
plot(x1, y1);
h2 = subplot(2, 1, 2);
plot(x2, y2)
set(h1, 'ButtonDownFcn', {'PlotNewFigure', x1, y1, 123})
set(h2, 'ButtonDownFcn', {'PlotNewFigure', x2, y2, 456})
PlotNewFigure that I used in this code is a seperate function (saved in another m file).
function PlotNewFigure(varargin)
figure(varargin{5});
plot(varargin{3}, varargin{4})
end
  6 comentarios
Shawn Fernandes
Shawn Fernandes el 19 de Feb. de 2017
Hi,
The above solution is working for plot, but not working for imshow matrix, PFB code.
function PlotNewFigure(varargin)
if(varargin{6}==0)
figure(varargin{5});
plot(varargin{3}, varargin{4})
end
if(varargin{6}==1)
figure(varargin{5});
imshow(varargin{3})
end
if(varargin{6}==2)
figure(varargin{5});
imshow(varargin{3},jet(varargin{4}))
end
end

Iniciar sesión para comentar.

Más respuestas (1)

maycon moreira
maycon moreira el 20 de Abr. de 2018
Hi,
I can not apply the same method in my code, how do I do that?
A=imread('cam.png'); subplot(4,3,1) imshow(A) title('Image A'); B=imread('futurama.jpg'); subplot(4,3,2) imshow(B) title ('Image B');

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by