Bug when using data cursor with subplots having (some) equal X and Y values
1 vue (au cours des 30 derniers jours)
Afficher commentaires plus anciens
Im using R2014b. When i have a figure with multiple subplots and I use the data cursor I get the following bug: If I click on a point in any of the subplots, lets say at X=1,Y=1, a tooltip will appear and a marker (square) will be placed on that point, which is how it is supposed to work. However, when I click on the same position on a different subplot, the tooltip will stay at the same position, the old marker will become transparent and a new marker will be placed in the new subplot. Afaik this is a bug. To be clear, this only happens if I click on the same exact position in a different subplot (assuming a data point exists there). Figure 1 (correct behavior):
Figure 2 (bug, occuring when I click on the same position but in a different subplot)
Is there any solution or workaround for this? I tried checking the properties of the tooltip but I couldnt figure anything out. I found out that if I use copyobj to make a new tooltip (copy of the old one) it will actually display correctly.
Code to make the figures:
figure;subplot(2,1,1);
plot([1 1 1],'x')
subplot(2,1,2);
plot([0 1 2],'rx')
0 commentaires
Réponses (2)
Vidya Viswanathan
le 1 Avr 2016
Hi Paul,
Thank you for reporting this issue to us. I was able to reproduce this behavior at my end. I will forward this information to the developers and they might consider fixing it in one of the future releases. Meanwhile, if I come up with a workaround, I will post it here.
Regards,
Vidya
0 commentaires
Jasper van Casteren
le 22 Nov 2018
This is caused by the fact that the datacursor is actually bound to the figure, not the axes.
I use
fig = figure;
ax1 = subplot(whatever);
ax2 = subplot(whatever);
datacursor = datacursormode(fig);
datacursor.set('UpdateFcn',@MyFunc);
% MyFunc must be an embedded function to know ax1 and ax2
function MyFunc(Target, evtObj)
if Target.Parent==ax1
whatever;
else
whatever;
end
end
To get the corretc datacursor text for each subplot.
0 commentaires
Voir également
Catégories
En savoir plus sur Subplots 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!