setting WindowButtonMotionFcn to several subplots. Later command set(gcf, 'WindowBut​tonMotionF​cn'...) work only for last suplot

4 vues (au cours des 30 derniers jours)
Hi
I have a figure with 2 subplot
f=figure
subplot(2,1,1)
plot(...)
% Then I set WindowButtonMotionFcn with my function highlightPlot_1
set(gcf, 'WindowButtonMotionFcn', @(src,event)highlightPlot_1(hittest(src)));
% if I make a breackpoint here, it works for 1st subplot
% Then I plotting another subplot
subplot(2,1,2)
plot(...)
%and again set WindowButtonMotionFcn with my another function highlightPlot_2
set(gcf, 'WindowButtonMotionFcn', @(src,event)highlightPlot_2(hittest(src)));
% at the end WindowButtonMotionFcn works only for 2nd subplot. It seems like 2nd set(gcf, ...) command overwrites previous one.
% And I understood that I cannot set WindowButtonMotionFcn for specific subplot?
So is it possible to have two working WindowButtonMotionFcn for each of subplot?
...You can say like separate subplots to two figures - prabably it will work but I want to have it in subplots.
Thanks!

Réponses (0)

Produits


Version

R2019a

Community Treasure Hunt

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

Start Hunting!

Translated by