0
$\begingroup$

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

$\endgroup$
2
  • $\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$ Commented Jul 21, 2016 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$ Commented Jul 21, 2016 at 21:10

1 Answer 1

-1
$\begingroup$

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

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.