How to set axis values using a vector.
8 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
Dear all, I actually got a problem to plot the correct values of the axis on my figures. Basically, I got a 2048x2048 matrix containing intensities which I plot using the imagesc function. Then the values of my axis are in pixels, not the unit I would like to use... I have calculated in two others matrices (of the same size) the values of the pixels in the unit I want for x and y, but I do not see how to combine these matrices with my figure. When I reduced the matrix to a vector of 2048x1 and I use set(gca,'XTickLabel', X), the values I got are not the good one. Do anyone got an idea ?
1 comentario
Jan
el 19 de Ag. de 2012
What does "the values are not the good one" mean? Did you explain explicitly, what you want to achieve?
Respuesta aceptada
Sven
el 19 de Ag. de 2012
Hi Jonathon,
I think your problem has one of the following solutions:
1. Your image is a perfect "grid", but you want to specify the xticks/yticks when you view it, rather than have it based on pixel number:
% Just get an image to test with
I = imread('rice.png');
% Get some xy vectors
xVec = linspace(50, 100, size(I,2));
yVec = linspace(10, 30, size(I,1));
% Show the image two different ways
figure, imagesc(I);
figure, imagesc(xVec,yVec,I)
The first figure there will be what you have at the moment (the image scaled by pixel numbers). The second figure will be scaled by the two vectors you specify. I think that this is what you want.
2. An imperfect grid.
There is a little quirk with the image()/imagesc() function that it always assumes your image is a perfect grid. In other words, it assumes that diff(xVec) and diff(yVec) in the above example will each give a row of identical numbers. If you don't want them perfectly spaced, there is a file exchange entry called uimage() which will help you.
3. A morphed image.
I don't think this is what you're looking for... but let me know if answer 1 or 2 don't quite do what you want to do.
0 comentarios
Más respuestas (0)
Ver también
Categorías
Más información sobre Grid Lines, Tick Values, and Labels en Help Center y File Exchange.
Productos
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!