0

I was wondering if there is a quick way to have, in a 2D plot, the x-axis oriented vertically, from top to bottom. I am looking for the Matlab equivalent of

 set(gca,'view',[90,90])

if any.

The only solution I found is How can I rotate a matplotlib plot through 90 degrees? but I cannot make in work because I have several plots on the figure

Community
  • 1
  • 1

1 Answers1

0

One way you could accomplish this is just to swap the X, Y values you pass to the function. For example, if you have lists of X values and Y values (the points are (X[i], Y[i]), you could just do:

scatter(Y,X)

instead of

scatter(X,Y)
TravisJ
  • 1,592
  • 1
  • 21
  • 37
  • The x-axis in this case will still point from the origin upward, not from the top down. I just re-read your post and I see you may have been looking for that. You can accomplish the "down" pointing by multiplying all your X-values by -1 (and doing the reverse mentioned here). – TravisJ Jan 16 '15 at 18:10
  • I thought about it..only it seems weird to me that matplotlib is missing such a basic feature – mattiaspeziali Jan 17 '15 at 17:51
  • I cannot accomplish the downward pointing as you suggested because I need to have a logarithmic x-axis, so I cannot negate the values @TravisJ – mattiaspeziali Jan 19 '15 at 09:55
  • The best I can do is `plot(y,-log(x))` – mattiaspeziali Jan 19 '15 at 09:57
  • You could negate the x-values then translate them upwards (so that the smallest one is still greater than 0). For example, if your x-range is -10 to 100, multiplying by -1 gives a range of -100 to 10, then shift everything up by say 101, so you have a range of 1 to 111. – TravisJ Jan 20 '15 at 14:06