使用Pandas在Python中绘制直方图 [英] Plotting histograms in Python using pandas

查看:884
本文介绍了使用Pandas在Python中绘制直方图的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试创建一个相互重叠的两个数据集的直方图,但是,每当我使用pandas.DataFrame.hist()绘制直方图时,它都会创建两个图形:

I'm trying to create a histogram with two data sets overlying each other, however whenever I plot it using pandas.DataFrame.hist(), it creates two graphs:

代码很简单:

ratios.hist(bins = 100)
plt.show()

其中比率只是一个DataFrame,2列乘以7000行.关于如何将两个图形放在同一轴上的任何想法吗?

where ratios is just a DataFrame, 2 columns by about 7000 rows. Any idea on how to put the two graphs on the same axis?

推荐答案

尝试这将生成:

ratios.plot.hist(alpha=0.5, bins=10)

另一方面,这将它们放在同一张图上:

This, on the other hand, puts them on the same graph:

这篇关于使用Pandas在Python中绘制直方图的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆