相关疑难解决方法(0)

matplotlib/pandas中是否有一个参数使直方图的Y轴为百分比?

我想通过让Y轴显示整个数据集大小中每列的百分比而不是绝对值来比较两个直方图.那可能吗?我正在使用Pandas和matplotlib.谢谢

python matplotlib pandas

45
推荐指数
6
解决办法
5万
查看次数

将数据帧绘制为同一图上的'hist'和'kde'

我有一个dataframe包含用户信息的熊猫.我想在同一个情节中将用户的年龄绘制为a kind='kde'和on kind='hist'.目前我能够拥有两个独立的情节.数据框类似于:

member_df=    
user_id    Age
1          23
2          34
3          63 
4          18
5          53  
...
Run Code Online (Sandbox Code Playgroud)

运用

ax1 = plt.subplot2grid((2,3), (0,0))
member_df.Age.plot(kind='kde', xlim=[16, 100])
ax1.set_xlabel('Age')

ax2 = plt.subplot2grid((2,3), (0,1))
member_df.Age.plot(kind='hist', bins=40)
ax2.set_xlabel('Age')

ax3 = ...
Run Code Online (Sandbox Code Playgroud)

我明白,这kind='kde'将给我y轴的频率,而 kind='kde'将给出累积分布,但有没有办法结合两者,并让y轴由频率表示?

python plot matplotlib dataframe pandas

9
推荐指数
1
解决办法
5577
查看次数

标签 统计

matplotlib ×2

pandas ×2

python ×2

dataframe ×1

plot ×1