Info

This question is closed. Reopen it to edit or answer.

How to flip axis on an image?

1 view (last 30 days)
Richard Mcnair
Richard Mcnair on 26 Sep 2021
Closed: Richard Mcnair on 26 Sep 2021
So, I have an image with an axis, but the axis is flipped compared to how I want it. The axis variables are t, and if I first say t = flip(t), I now get the correct image with the axis correct, but it is now upside down.
I have looked at other Matlab questions, for example
But the solutions presented dont solve my problem. The best solution I have found so far is the following code
yLimits = get(gca,'YLim'); %# Get the y axis limits
yTicks = t(end)+t(1)-get(gca,'YTick'); %# Get the y axis tick values and
%# subtract them from the upper limit
set(gca,'YTickLabel',num2str(yTicks.')); %'# Convert the tick values to strings
%# and update the y axis labels
This works, the axis is correct, and the image is the correct way up, but the choice of ticks is now wierd. Instead of having ticks at 0, 0.1, 0.2, etc, I have ticks at 0.11334 and other strange values. I have really tried everything with this. Why does doing t = flip(t) also flip the image?
  1 Comment
Richard Mcnair
Richard Mcnair on 26 Sep 2021
I've just done it. It can be done in a single line of code:
view([0,-90])

Answers (0)

This question is closed.

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!