Reputation: 13
I have to realize a histogram using matplotlip and plotly. But I am stuck because there are so many options available and with so don't manage to have a proper histogram with all the online tutorials. My data is a matrix of two columns and 20000 rows. I use those commands, but it didn't work.
here is my code:
with open('rmsd.dat') as f:
v = np.loadtxt(f, delimiter= ' ')
plt.hist(v, bins=100)
plt.xlabel("G-r0")
plt.ylabel('# of stars')
plt.title("RMSD histogramm")
plt.show()
In a second time the histogram has to be horizontal and near another plot using the same data I tried to use matplotlib and plotly but it was a big mess
that all
Upvotes: 0
Views: 278
Reputation: 11
Your data has two columns, so you must to indicate which column you want to plot.
import matplotlib.pyplot as plt
data[:,0] #shape (3000,2)
plt.hist(data[:,0],bins=100)
Or horizontal:
plt.hist(data[:,0],bins=100,orientation='horizontal')
If I just use plt.hist(data,bins=30)
it will appear like a simple bar plot.
Upvotes: 1