Make larger plot when mouse hover over subplot

1 回表示 (過去 30 日間)
Etienne Coetzee
Etienne Coetzee 2018 年 10 月 9 日
編集済み: jonas 2018 年 10 月 9 日
Hi All
I have a subplot of 8 x 8 parameters. I would like to implement a feature where a larger plot appears of the subplot I am hovering over with the mouse. I would prefer not to have to click the mouse. I am not sure how to implement this because I noticed some other posts mentioning that it is not possible to find axes handles in panels. Any help would be appreciated.
Regards
Etienne

採用された回答

jonas
jonas 2018 年 10 月 9 日
編集済み: jonas 2018 年 10 月 9 日
I wrote a little demo for how you can program this using callbacks. The reason I wrote it is because I am trying to learn callbacks, so I am by no means an expert :)
The current callback function is quite costly, but it works!
figure;
set(gcf,'units','normalized')
% Some dummy plots
for i=1:9
ax{i}=subplot(3,3,i)
plot(rand(10,10))
end
% Get axes position and convert to polygons
pos = get([ax{:}],'position')
poly = cellfun(@(x)[x(1),x(1)+x(3),x(1)+x(3),x(1);x(2),x(2),x(2)+x(4),x(2)+x(4)],pos,'uniformoutput',false)
% Initiate callback
set(gcf,'WindowButtonMotionFcn',{@FigCallback,poly,pos,ax})
% Callback function
function FigCallback(scr,evnt,poly,pos,ax,~)
C = get(gcf, 'CurrentPoint');
in = cellfun(@(x)inpolygon(C(1),C(2),x(1,:)',x(2,:)'),poly)
if sum(in)>0
sum(in)
set(ax{in},'Position',pos{in}.*[.8 .8 1.2 1.2])
uistack(ax{in},'top')
else
cellfun(@(x,y)set(x,'position',y),ax',pos)
end
end

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeVisual Exploration についてさらに検索

製品

Community Treasure Hunt

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

Start Hunting!

Translated by