holoviews icon indicating copy to clipboard operation
holoviews copied to clipboard

'bins' keyword argument ignored in histogram

Open TheoMathurin opened this issue 3 years ago • 5 comments

Hi,

It seems like setting the number of bins through the bins keyword argument in histograms does nothing.

Let's take an example in the Holoviews demos:

import holoviews as hv
from holoviews import opts
hv.extension('bokeh')
from bokeh.sampledata.autompg import autompg

autompg_ds = hv.Dataset(autompg)
hist = autompg_ds.hist(dimension='mpg', groupby='cyl', bin_range=(9, 46), bins=40, adjoin=False)
hist.opts(opts.Histogram(alpha=0.9, width=600))

Setting bins to 40 or 10 or 100 does not change the output. Note that I encounter the same behavior when using histogram() from holoviews.operation.element.

Or maybe I'm getting something wrong?

Config:

  • Holoviews 1.13.4
  • Jupyter notebook with bokeh backend
  • Python 3.8
  • Browser: Chromium / Firefox
  • OS: CentOS 7

TheoMathurin avatar Oct 19 '20 13:10 TheoMathurin

I can confirm this behaviour.

OS: Ubuntu 20.04.1 LTS Packages: Python 3.7.9 Holoviews 1.14.1 Bokeh 2.2.3 Firefox 84.0

TizianoGC avatar Jan 10 '21 15:01 TizianoGC

me too.

  • OS: CentOS 7.9-2009
  • Python 3.6.13
  • Holoviews 1.14.4
  • bokeh 2.3.0
  • matplotlib 3.3.4
  • Chrome: 92.0

hiroshi80 avatar Aug 20 '21 07:08 hiroshi80

The command to use is num_bins. Sorry for the late answer.

image

image

image

hoxbro avatar Sep 08 '22 12:09 hoxbro

A little surprised that setting bins to an integer does not raise an error as it should only support np.ndarray, list, tuple, str as seen here:

https://github.com/holoviz/holoviews/blob/6c0dafb8dc0b2c059b0cfbf49908c51f243c309c/holoviews/operation/element.py#L659

So it seems that histogram bypasses the __init__ and therefore never validates the parameters. Do you have an explanation for this, @jlstevens?

hoxbro avatar Sep 08 '22 12:09 hoxbro

Ok so this is more of a usage/docs issue. Please don't hesitate to close the issue or update it accordingly.

TheoMathurin avatar Sep 09 '22 14:09 TheoMathurin

A little surprised that setting bins to an integer does not raise an error as it should only support

I was surprised too, but it's actually a long-standing issue with ParamOverrides https://github.com/holoviz/param/issues/85

maximlt avatar Oct 19 '22 08:10 maximlt

Ah yes. Someone should do something about https://github.com/holoviz/param/issues/85!

jbednar avatar Oct 21 '22 03:10 jbednar