首页 > 编程语言 > 详细

Python 笔记 #10# Histograms

时间:2018-01-14 20:02:45      阅读:408      评论:0      收藏:0      [点我收藏+]

1、Build a histogram

In [1]: help(plt.hist)
Help on function hist in module matplotlib.pyplot:

hist(x, bins=10, range=None, normed=False, weights=None, cumulative=False, bottom=None, histtype=bar, align=mid, orientation=vertical, rwidth=None, log=False, color=None, label=None, stacked=False, hold=None, data=None, **kwargs)
    Plot a histogram.

 技术分享图片

# Create histogram of life_exp data
plt.hist(life_exp);

# Display histogram
plt.show()

 

2、Bins

 技术分享图片技术分享图片

# Build histogram with 5 bins
plt.hist(life_exp, bins = 5)

# Show and clean up plot
plt.show()
plt.clf()

# Build histogram with 20 bins
plt.hist(life_exp, bins = 20)

# Show and clean up again
plt.show()
plt.clf()

 

3、Compare

# Histogram of life_exp, 15 bins
plt.hist(life_exp, bins = 15)

# Show and clear plot
plt.show()
plt.clf()

# Histogram of life_exp1950, 15 bins
plt.hist(life_exp1950, bins = 15)

# Show and clear plot again
plt.show()
plt.clf()

 

Python 笔记 #10# Histograms

原文:https://www.cnblogs.com/xkxf/p/8283996.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!