Python: ggplot geom_histogram() binwidth or bin parameter missing?

I am unable to change number of bins when using geom_histogram() function. There is nothing in the documention, except some examples where binwidth=X is used (which is how R:ggplot2 uses it). However, this parameter seems to have no effect on the actual output.

Version: ggplot 0.10.4, Python 3.5 64bit

So for example:

import matplotlib.pyplot as plt
plt.figure()
dataframe['column'].plot.hist(bins=30)
plt.show()


works as expected and draws 30 bins. Meanwhile:

from ggplot import *
gg = ggplot(dataframe, aes(x='column')) + geom_histogram(binwidth=300)
print(gg)


does not change number of bins (I understand that binwidth sets interval for one bin), and have tried multiple values and/or datasets

• Never used ggplot in python. But in R, you want to use geom_histogram(bins=30), not binwidth, which refers to the width of each bin and cannot be used in combination with bins. (By default, bins=30 by the way,) – Ricardo Cruz Jul 21 '16 at 20:34
• As Python's ggplot is built on top on matplotlib I would expect that bins=X parameter should be working but it is not. – Andis Jul 21 '16 at 21:10

1 Answer

bins=10 parameter is actually added in latest version (ggplot 0.11) https://github.com/yhat/ggplot/issues/513