Rescale tick marks on UIAxes
3 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Steven Manz
am 31 Aug. 2022
Kommentiert: Steven Manz
am 31 Aug. 2022
I have a figure that represents a grayscale image. Its resolution is 1280x960. If I show the axes, this is what it shows. When I zoom in, I get the proper vector scaled axis tick marks.
I want to change the tick marks to be distance rather than resolution. I have created my own internal function that will determine pixel distance related to the scale given on the image.
For this note that:
pixel_distance = 0.1;
The image is attached. Here is the code I use to generate tick marks:
xlen = rescale(get(app.UIAxes,'xtick'),0,size(image,2)*pixel_distance);
ylen = rescale(get(app.UIAxes,'ytick'),0,size(image,1)*pixel_distance);
xt=arrayfun(@num2str,xlen,'un',0);
yt=arrayfun(@num2str,ylen,'un',0);
set(app.UIAxes,'xticklabel',xt,'yticklabel',yt)
set(app.UIAxes,'xtick',xlen,'ytick',ylen)
But this gives the wrong output:
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/1112870/image.png)
If I just use this code:
xlen = rescale(get(app.UIAxes,'xtick'),0,size(image,2)*pixel_distance);
ylen = rescale(get(app.UIAxes,'ytick'),0,size(image,1)*pixel_distance);
xt=arrayfun(@num2str,xlen,'un',0);
yt=arrayfun(@num2str,ylen,'un',0);
set(app.UIAxes,'xticklabel',xt,'yticklabel',yt)
I am only setting the label string values but not the physical quantities. So when I scroll in the tick marks do not change as they should.
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/1112875/image.png)
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/1112880/image.png)
Does somebody know how I can correctly fix the scaling on the tick marks to represent distance rather than resolution?
0 Kommentare
Akzeptierte Antwort
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu Axis Labels finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!