在 pandas 直方图中设置y轴限制 [英] Set y axis limit in Pandas histogram

查看:100
本文介绍了在 pandas 直方图中设置y轴限制的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用熊猫直方图.

I am using Pandas histogram.

我想设置绘图的y轴范围.

I would like to set the y-axis range of the plot.

这里是上下文:

import matplotlib.pyplot as plt
%matplotlib inline

interesting_columns = ['Level', 'Group']

for column in interesting_columns:
    data['ranking'].hist(by=data[column], normed=True)

有一个范围参数可以过滤x值,但我不知道y等效项:

There is a range argument that can filter x-values, but I am unaware of the y equivalent:

hist(by=[column], normed=True, range=[0, 1]) #working argument
hist(by=[column], normed=True, y_range=[0, 1]) #hypothetical argument

我已经阅读了许多使用plt属性更改绘图范围的不同方法.它们似乎并没有循环工作,也无法为子图工作.

I've read a lot of different methods for changing plot ranges using plt attributes. They do not seem to work in a loop and for subplots.

我正在努力掌握解决此问题的正确方法.

I am struggling to grasp the right way to approach this problem.

推荐答案

如果使用

data['ranking'].plot.hist(ylim=(0,1)) 

它应该工作.

这篇关于在 pandas 直方图中设置y轴限制的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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