holoviews
holoviews copied to clipboard
'bins' keyword argument ignored in histogram
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
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
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
The command to use is num_bins
. Sorry for the late answer.
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?
Ok so this is more of a usage/docs issue. Please don't hesitate to close the issue or update it accordingly.
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
Ah yes. Someone should do something about https://github.com/holoviz/param/issues/85!