带固定xlabel的Python正态分布图
我是python新手,在过去的两天里我一直在绘制正态分布图。 我有一个列表h=[33186,67180,90,78],但我希望x轴有一个固定的字符串值 对于实例xlabels的每个索引=['A'、'B'、'C'、'D'、'E'、'F'] 我试过了带固定xlabel的Python正态分布图,python,Python,我是python新手,在过去的两天里我一直在绘制正态分布图。 我有一个列表h=[33186,67180,90,78],但我希望x轴有一个固定的字符串值 对于实例xlabels的每个索引=['A'、'B'、'C'、'D'、'E'、'F'] 我试过了 由于某些原因,我没有得到正确的答案,有什么帮助吗?这是否提供了所需的输出 import numpy as np import scipy.stats as stats import pylab as plt h = sorted([33,186,67
由于某些原因,我没有得到正确的答案,有什么帮助吗?这是否提供了所需的输出
import numpy as np
import scipy.stats as stats
import pylab as plt
h = sorted([33,186,67,180,90,78]) #sorted
fit = stats.norm.pdf(h, np.mean(h), np.std(h)) #this is a fitting indeed
fig, ax = plt.subplots()
ax.plot(h,fit,'-o')
ax.hist(h,density=True) #use this to draw histogram of your data
labels = ['A','B','C','D','E','F']
plt.xticks(ticks=h, labels=labels)
plt.show()
import numpy as np
import scipy.stats as stats
import pylab as plt
h = sorted([33,186,67,180,90,78]) #sorted
fit = stats.norm.pdf(h, np.mean(h), np.std(h)) #this is a fitting indeed
fig, ax = plt.subplots()
ax.plot(h,fit,'-o')
ax.hist(h,density=True) #use this to draw histogram of your data
labels = ['A','B','C','D','E','F']
plt.xticks(ticks=h, labels=labels)
plt.show()