Set y axis limit in Pandas histogram

人盡茶涼 提交于 2019-12-10 12:56:16

问题


I am using Pandas histogram.

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

Here is the context:

import matplotlib.pyplot as plt
%matplotlib inline

interesting_columns = ['Level', 'Group']

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

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

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.


回答1:


If you use

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

it should work.



来源:https://stackoverflow.com/questions/38424459/set-y-axis-limit-in-pandas-histogram

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!