Rescale tick marks on UIAxes
Mostrar comentarios más antiguos
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:

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.
_______________ 
Does somebody know how I can correctly fix the scaling on the tick marks to represent distance rather than resolution?
Respuesta aceptada
Más respuestas (0)
Categorías
Más información sobre Graphics Object Properties en Centro de ayuda y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!