python绘制对数坐标图描点_用Matplotlib在对数刻度上绘制直方图

本文介绍了如何在Python中使用pandas和matplotlib库绘制对数坐标系的直方图。当数据范围差距较大时,通过设置不等宽的直方图 bins,使其在对数尺度上看起来均匀分布,解决了在对数坐标下直方图显示不佳的问题。

I have a pandas DataFrame that has the following values in a Series

x = [2, 1, 76, 140, 286, 267, 60, 271, 5, 13, 9, 76, 77, 6, 2, 27, 22, 1, 12, 7, 19, 81, 11, 173, 13, 7, 16, 19, 23, 197, 167, 1]

I was instructed to plot two histograms in a Jupyter notebook with Python 3.6. No sweat right?

x.plot.hist(bins=8)

plt.show()

I chose 8 bins because that looked best to me.

I have also been instructed to plot another histogram with the log of x.

x.plot.hist(bins=8)

plt.xscale('log')

plt.show()

This histogram looks TERRIBLE. Am I not doing something right? I've tried fiddling around with the plot, but everything I've tried just seems to make the histogram look even worse. Example:

x.plot(kind='hist', logx=True)

I was not given any instructions other than plot the log of X as a histogram.

I really appreciate any hel

评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符  | 博主筛选后可见
 
红包 添加红包
表情包 插入表情
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值