Bug when using data cursor with subplots having (some) equal X and Y values
1 回表示 (過去 30 日間)
古いコメントを表示
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 件のコメント
回答 (2 件)
Vidya Viswanathan
2016 年 4 月 1 日
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 件のコメント
Jasper van Casteren
2018 年 11 月 22 日
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 件のコメント
参考
カテゴリ
Help Center および File Exchange で Subplots についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!