How do I vertically flip text on the axis of a plot in MATLAB?
I'm having an issue开发者_Go百科 where I have a surface and an image I want to display side by side. To do this I used this code.
figure(1)
subplot(1,2,1)
axis([0 100 0 100 0 1])
surf(x,y,z)
title(['Surface Title'])
subplot(1,2,1)
image(my_image)
title(['Image Title'])
What happens is the
1) The figure is created 2) The first subplot is created 3) The surface is rendered with proper axis and title. 4) The second subplot is created
After that unexpected things start happening. When the image is rendered the text on the image is flipped vertically. Is this expected behavior? If not is there a way to flip the text on the axis?
From the documentation page of the image function:
By default, image plots the y-axis from lowest to highest value, top to bottom. To reverse this, type set(gca,'YDir','normal'). This will reverse both the y-axis and the image.
Or you can simply issue the command: axis xy
Here is an example:
[X,Y,Z] = peaks;
subplot(121), surf(X,Y,Z)
axis([-5 5 -5 5 -10 10])
title('Surface Title')
xlabel x, ylabel y, zlabel z
subplot(122), imagesc(Z)
axis xy
title('Image Title')
精彩评论