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

16 ビュー (過去 30 日間)
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!

採用された回答

emehmetcik
emehmetcik 2015 年 2 月 15 日
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 件のコメント
William
William 2015 年 2 月 19 日
Thank you again!I understand it now with your help.
Shawn Fernandes
Shawn Fernandes 2017 年 2 月 19 日
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

サインインしてコメントする。

その他の回答 (1 件)

maycon moreira
maycon moreira 2018 年 4 月 20 日
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');

カテゴリ

Help Center および File ExchangeMigrate GUIDE Apps についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by