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

works as expected and draws 30 bins. Meanwhile:

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

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

  • $\begingroup$ 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,) $\endgroup$ – Ricardo Cruz Jul 21 '16 at 20:34
  • $\begingroup$ As Python's ggplot is built on top on matplotlib I would expect that bins=X parameter should be working but it is not. $\endgroup$ – Andis Jul 21 '16 at 21:10

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


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.