Show image in UIAxis with updated axis limits
9 views (last 30 days)
Show older comments
I am using a function that outputs the x and y axis values, an image data matrix, and image colormap. I would like to put the image in a UIAxis and update the limits to represent the new x and y axis values.
This code gets me the image I would like with cooresponding axis values.
imagesc(X,Y,M)
colormap(Mcolor)
The following code shows the correct image in the UIAxis but the axis values are now based on the pixels of the image.
imagesc(app.UIAxes,M);
colormap(app.UIAxes,Mcolor);
Manually changing the axis limits just makes the images very small.
How do I get the correct axis values with the image in the UIAxis?
4 Comments
Answers (1)
Adam Danz
on 27 Aug 2019
If you do not supply the x and y values, the axes will represent a pixel count. If you want want the x and y axes to represent a different metric (miles, meters, KMs, etc) you need to supply those values just like you did in the first line of code in your question.
imagesc(app.UIAxes,X,Y,M)
Then, to trim the axes to fit the image,
axis(app.UIAxes,'tight')
You may also need to make the aspect ratio equal so the image is not skewed along one of the axes.
axis(app.UIAxes,'equal')
0 Comments
See Also
Categories
Find more on Graphics Object Programming in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!