Reputation: 31
import matplotlib.pyplot as plt
import numpy as np
import xlrd
import xlwt
wb = xlrd.open_workbook('Scatter plot.xlsx')
sh1 = wb.sheet_by_name('T180')
sh2=wb.sheet_by_name("T181")
sh3=wb.sheet_by_name("Sheet1")
x= np.array([sh1.col_values(7, start_rowx=50, end_rowx=315)])
x1= np.array([sh2.col_values(1, start_rowx=48, end_rowx=299)])
y=np.array([sh1.col_values(2, start_rowx=50, end_rowx=299)])
y1= np.array([sh2.col_values(2, start_rowx=48, end_rowx=299)])
print x
plt.hist(x,bins=50)
plt.xlabel("dx (micron)")
plt.ylabel("dy (micron)")
plt.show()
As you can see the figure from link is obtained by this code. Why this histogram is like this?
How can I solve it? Thanks in advance for your kind help.
Upvotes: 0
Views: 3796
Reputation: 31
Yes it was working nicely according to the suggestions by HYRY. Thank to @ HYRY.
plt.hist(x.ravel(),bins=100,histtype="step",label="Before Translation")
Upvotes: 0
Reputation: 97291
The shape of x
is (1, 265)
, it's a 2-dim array, you need to convert it to 1-dim array first:
plt.hist(x.ravel(), bins=50)
Upvotes: 2