Horizontal graph in python

I am looking for a graph that rotates 90 degrees clockwise. A similar example of such a graph is "hist (x, orientation = 'horizontal')." Is there a way to achieve a similar orientation.

#Make horizontal plots. import random import matplotlib.pyplot as plt x = random.sample(range(1000), 100) x plt.plot(x) #orientation='horizontal' plt.show() 
+4
source share
1 answer

plt.plot(x) automatically groups your x values ​​along the y axis. To get the rotation, you have to plot your x values ​​along the x axis. So you need a to make a vector for the y axis, which is the same length as your sample.

 import random import matplotlib.pyplot as plt import numpy as np x=random.sample(1000) y=np.arange(1000) plt.plot(x,y) 

Using plt.plot(x) , matplotlib takes your x values ​​as its y values ​​and automatically creates a vector for the x axis.

+2
source

Source: https://habr.com/ru/post/1432850/


All Articles