Create custom x-axis for 'imagesc' plot
Mostrar comentarios más antiguos
I am trying to create a custom x-axis for my imagesc plot using a separate vector ('xaxis') with increasing values from -150.36 to 265.8773.
However, I am facing an issue where when I set this vector as my x-axis, it appears only for half of the image. The vector 'xaxis' has the same length as the x-axis pixels in the image and I would like it's values to represent each x-axis pixel rather than the default which only has the pixel value listed.
My intention is to then evenly space out the x-axis ticks using the label command after setting the x-axis to 'xaxis' to avoid overwriting/bunching together.
Original x-axis;

x-axis from vector 'xaxis':

From the image, I understand that the ticks only go to half the image before starting over and overwriting the previous ticks.
Any tips would be highly appreciated.
Below is my code for setting the x-axis to the desired tick values;
colormap gray;
%subplot(2,2,1);
imagesc(inclinedCyl_d20);
ax = gca;
ax.XTick = [xaxis];
Respuesta aceptada
Más respuestas (1)
Image Analyst
el 4 de Jul. de 2020
If you use imshow(), you can simply pass in the endpoints of the x axis to the 'XData' property:
imshow('moon.tif', 'XData', [-150.36, 265.8773]);
3 comentarios
Kevin Mutai
el 4 de Jul. de 2020
Image Analyst
el 4 de Jul. de 2020
Of course:
imshow(inclinedCyl_d20, [], 'XData', [-150.36, 265.8773]);
Kevin Mutai
el 4 de Jul. de 2020
Categorías
Más información sobre Graphics 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!