1

Usually matplotlib uses this axis:

Y
|
|
|_______X

But I need to plot my data using:

  _________Y
 |
 |
 |
 X

How can I do it? I will prefer not modify my data (i.e. transposing). I need to be able of use the coordinates always and matplotlib changes the axis.

PabloRdrRbl
  • 247
  • 2
  • 10

1 Answers1

2

One of the variations:

import matplotlib.pyplot as plt

def Scatter(x, y):        
    ax.scatter(y, x) 

#Data preparation part:
x=[1, 2, 3, 4, 5]
y=[2, 3, 4, 5, 6]  

#Plotting and axis inverting part
fig, ax = plt.subplots(figsize=(10,8))
plt.ylabel('X', fontsize=15)
plt.xlabel('Y', fontsize=15)

ax.xaxis.set_label_position('top') #This send label to top 
plt.gca().invert_yaxis() #This inverts y axis
ax.xaxis.tick_top() #This send xticks to top

#User defined function Scatter
Scatter(x,y)

ax.grid()
ax.axis('scaled') 
plt.show()

Output:

enter image description here

Erba Aitbayev
  • 4,167
  • 12
  • 46
  • 81