MATLAB Answers

GIRAY
0

How to adjust the x-axes and y-axes values without resizing the image/figure?

GIRAY
さんによって質問されました 2013 年 6 月 26 日
Hey all,
I am working on a GUI, where I want to display the output on a figure window. So for giggles, I will make the following example as a reference, and if you have some suggestions, you can pitch in your ideas based upon this example.
Let's assume that I am displaying on a figure window, an image. So the following code is going to display peaks(256) on the figure.
img=peaks(256);
hFigure=figure; hAxes=axes;
set(hFigure,'name','My Image', 'numbertitle', 'off');
hImage=image(img);
set(hAxes,'Layer','top','xgrid','on','ygrid','on');
So the problem I have is that this plot will have limits that range from 0-255 in x and y directions. I want to scale the axes numbers without manipulating the image or resizing the image. In other words, max number should be, for example, not 255, but 25.5 in all directions, hence the range of 0-25.5.
In essence the goal is to just modify the string values of the axes. How can I access the values of the axes? I can do num2str and spit the scaled numbers back to the figure, but how?
All answers are greatly appreciated. Thanks. Giray.

  0 件のコメント

サインイン to comment.

2 件の回答

回答者: Tom
2013 年 6 月 26 日
 採用された回答

AX = axes;
plot(rand(5))
oldTick = get(AX,'YTick'); %get the current tick points of the y axis
newTickStr = cellstr(num2str(oldTick'/10)); %create a cell array of strings
set(AX,'YTickLabel',newTickStr)

  0 件のコメント

サインイン to comment.


回答者: GIRAY
2013 年 6 月 26 日

Tom, You are the man!
Thank you very much. Regards, Giray.

  0 件のコメント

サインイン to comment.



Translated by