Why data cursor showing wrong values?

I am working with 3D axes. Previously I have modified the z and y axes. I needed to have z and y values shown reversed. Not to go from 1 to 200 bit from 200 to 1. And now data cursor fetches the old data and is not in match with on screen data.
Any help would be appreciated.
Thanks.
note: I have changed the values like this:
yLimits = get(gca,'YLim');
yTicks = yLimits(2)-get(gca,'YTick');
set(gca,'YTickLabel',num2str(yTicks.'));

1 件のコメント

per isakson
per isakson 2012 年 11 月 28 日
Without checking, I think the ticklabels are just some text - could be any text. It doesn't change the underlying scale of the axis.
What more did you do to "have z and y values shown reversed"?

サインインしてコメントする。

 採用された回答

Tom Lane
Tom Lane 2012 年 11 月 28 日

0 投票

Try this instead:
set(gca,'YDir','reverse')
Your way retains the y tick locations and values, and just labels them with something else. For example, it may place the string "2.0" at the spot corresponding to y=1.0.

6 件のコメント

Tomislav
Tomislav 2012 年 11 月 28 日
Tom, this way tha data is upside-down too. I dont want that.
Per, exactly, the text has been changed only. But matlab remembers the real labels and shows them with cursor data when clicked. And they, obviously, do not match with labels.
Thanks.
Tom Lane
Tom Lane 2012 年 11 月 28 日
I don't understand. I did this:
x = (1:5); y = x.^2; z = log(x); plot3(x,y,z,'bs')
Then I ran your code to change the Y axis ticks. Then I put a data cursor on a point and it was labeled "X: 2, Y: 4, Z: 0.6931" even though the text I put onto the y axis "claims" the Y value is close to 20.
Suppose you place the string "30" at Y=0 and "20" at Y=10. What would you like the data cursor to display if you click on a point with Y=5?
If you are looking to create custom data cursor text just as you are providing custom tick labels, then "help datacursormode" is a starting point.
Tomislav
Tomislav 2012 年 11 月 29 日
Yes, "Then I ran your code to change the Y axis ticks. Then I put a data cursor on a point and it was labeled "X: 2, Y: 4, Z: 0.6931" even though the text I put onto the y axis "claims" the Y value is close to 20."
- This is the problem. I want that text on labels match with cursor. In your case cursor data should show "x:2, y: 20"
Thanks.
Tom Lane
Tom Lane 2012 年 11 月 29 日
Check out the last two paragraphs of my previous reply. The y value is really 4. You can either plot a 20, or use a custom data cursor. I don't see any way to trick the data cursor into inferring different desired y results from the text labels you put on the y axis tick marks.
Tomislav
Tomislav 2012 年 11 月 29 日
I will check datacursormode. I would like the same result on cursor as on text labels, not the real value of 4.
Thank you for all your help.
Tomislav
Tomislav 2012 年 11 月 29 日
I did it. previousley I have used
I=flipud(I);
and it messed things up, because it flipped the data while the labels stayed the same, and because of that I couldnt get what you were explaining.
Thank you all for your time.

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

質問済み:

2012 年 11 月 28 日

Community Treasure Hunt

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

Start Hunting!

Translated by