Data Cursor Position Issue
5 ビュー (過去 30 日間)
古いコメントを表示
I have a number of bar charts in a figure window and each has the datacursormode enabled. When I click on a bar with a negative value, a y position of 0 is returned. It seems to work fine for bars of positive values so I'm somewhat perplexed.
2 件のコメント
Richard
2011 年 6 月 20 日
A simple example ( bar(-5:5) ) works OK for me. Do you have some code that reproduces the problem? Also, which version are you using?
採用された回答
Richard
2011 年 8 月 3 日
Conor, sorry for the delay, I didn't notice your comment until today.
This is a bug in older versions of MATLAB. I can see the issue in v7.4 for a simple bar chart with a standard data cursor:
bar(-5:5)
For all of the bars, the data cursor is being placed at the maximum Y value instead of at the maximum absolute Y value, and for negative bars this is always 0 instead of being -5, -4, -3 etc. This incorrect value is also passed into your custom datatip function. There is no easy way to directly get the correct Y (RDI) value, however you could look up the X (Radii) value in the target's XData and then use the corresponding YData value:
xd = get(T, 'XData');
[~,idx] = min(abs(xd-P(1)));
yd = get(T, 'YData');
ThisRDI = yd(idx);
This bug has been fixed in a more recent version of MATLAB - I believe from R2008b onwards, so upgrading is another option.
その他の回答 (0 件)
参考
カテゴリ
Help Center および File Exchange で Annotations についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!