问题
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