Make larger plot when mouse hover over subplot

1 vue (au cours des 30 derniers jours)
Etienne Coetzee
Etienne Coetzee le 9 Oct 2018
Modifié(e) : jonas le 9 Oct 2018
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

Réponse acceptée

jonas
jonas le 9 Oct 2018
Modifié(e) : jonas le 9 Oct 2018
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

Plus de réponses (0)

Catégories

En savoir plus sur Visual Exploration dans Help Center et File Exchange

Produits

Community Treasure Hunt

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

Start Hunting!

Translated by