Swapping x & y Axis in Matlab
Asked Answered
N

1

6

Potentially easy matlab question here, but I've searched and can't sort out how to do this.

I've got a variables, which plot like this: Example

I simple want the x axis to be the y axis and vice versa. How do I swap them?

Thank you in advance for your help!!

Nephrosis answered 21/4, 2015 at 22:53 Comment(0)
V
12

The standard way would be to swap the arguments passed to plot:

plot(ydata, xdata) %// instead of plot(xdata, ydata)

Failing that, you can change the view to rotate the axes:

view([90 -90]) %// instead of normal view, which is view([0 90])
Volt answered 21/4, 2015 at 22:57 Comment(1)
The second answer is useful for area plots, because as far as I can tell from the documentation there is no way to make the baseline a vertical line. Commenting with the hope of making this solution easier to find for someone with the same issue that I had.Moria

© 2022 - 2024 — McMap. All rights reserved.