简体   繁体   English

如何更改 Python 中直方图的大小?

[英]How to change the size of histograms in Python?

在此处输入图像描述 I am trying to create a histogram but the values seem to be very small, so the size of the histogram is also small.我正在尝试创建直方图,但值似乎非常小,因此直方图的大小也很小。 What can I add to make it bigger?我可以添加什么使它更大? This is the code that I have:这是我拥有的代码:

plt.hist(my_data["Happiness Score"], bins=15, edgecolor ='white') 
#x and y labels:
plt.xlabel("Frequency")
plt.ylabel("Happiness Score")
textstr= 'Mean = 5.375734\nS.D =1.145010\nn = 158'
plt.text(40,50, textstr)
plt.axvline(x=5.375734,color='red',linestyle="dashed", label='mean')
plt.axvline(x=5.3757348 + 1.145010,color='green',linestyle="solid", label='S.D.')
plt.axvline(x=5.375734 - 1.145010,color='green',linestyle="solid")
plt.legend(loc='center right')
plt.show()

I think the fastest way is to use the figure(figsize) command.我认为最快的方法是使用 figure(figsize) 命令。 You can play with the values of the size however you like.您可以随意使用大小的值。

plt.figure(figsize=(10,8))

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM