0

I need to invert Y axis in my plt scatter plot. I tried this:

x = [5, 10, 65, 28, 0]
y = [0, 6, 17, 22, 27]

scatter = plt.scatter(x, y, s=1, alpha=1).invert_yaxis() #here I need to invert


plt.show()

In other words, I want to have value 27 in the left down corner and 0 in the top left corder. How can I fix it please?

vojtam
  • 1,157
  • 9
  • 34

1 Answers1

2

Use can use ax.invert_yaxis:

# create an axis instance with `subplots
fig, ax = plt.subplots()
scatter = ax.scatter(x, y, s=1, alpha=1) #here I need to invert
ax.invert_yaxis()   # here how you can invert

plt.show()

Output:

enter image description here

Quang Hoang
  • 146,074
  • 10
  • 56
  • 74