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!!

Luis Mendo
  • 110,752
  • 13
  • 76
  • 147
Laura
  • 93
  • 1
  • 1
  • 7

1 Answers1

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])
Luis Mendo
  • 110,752
  • 13
  • 76
  • 147
  • 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. – Filip Cvejic Jul 04 '21 at 11:41