Bug when using data cursor with subplots having (some) equal X and Y values
조회 수: 2 (최근 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!