Effacer les filtres
Effacer les filtres

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

16 vues (au cours des 30 derniers jours)
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!

Réponse acceptée

emehmetcik
emehmetcik le 15 Fév 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 commentaires
William
William le 19 Fév 2015
Thank you again!I understand it now with your help.
Shawn Fernandes
Shawn Fernandes le 19 Fév 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

Connectez-vous pour commenter.

Plus de réponses (1)

maycon moreira
maycon moreira le 20 Avr 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');

Catégories

En savoir plus sur Migrate GUIDE Apps dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by