Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding quartile breaks Violin plot #3358

Closed
Safrone opened this issue Dec 28, 2018 · 1 comment
Closed

Adding quartile breaks Violin plot #3358

Safrone opened this issue Dec 28, 2018 · 1 comment
Milestone

Comments

@Safrone
Copy link
Contributor

Safrone commented Dec 28, 2018

There is a case when rendering a Violin plot with 'quartiles' or 'stick' for the inner option will cause it to raise an exception.

Example:

import pandas as pd
import holoviews as hv

data_dict = {
    'time_of_day': {0: 16, 1: 17, 2: 18, 3: 19, 4: 20, 5: 21, 6: 22, 7: 23, 8: 0, 9: 1, 10: 2, 11: 3, 12: 4, 13: 5, 14: 6, 15: 7, 16: 8, 17: 9, 18: 10, 19: 11, 20: 12, 21: 13, 22: 14, 23: 15}, 
    'level': {0: 1, 1: 1, 2: 1, 3: 1, 4: 1, 5: 1, 6: 1, 7: 0, 8: 0, 9: 0, 10: 0, 11: 1, 12: 1, 13: 1, 14: 1, 15: 1, 16: 1, 17: 1, 18: 1, 19: 1, 20: 1, 21: 1, 22: 1, 23: 1}
}
df = pd.DataFrame(data_dict)

# Renders OK
hv.renderer('bokeh').static_html(hv.Violin(data=df, kdims='time_of_day', vdims='level'))

# Raises an exception
hv.renderer('bokeh').static_html(hv.Violin(data=d, kdims='time_of_day', vdims='level').opts(inner='quartiles'))

Exception:

Traceback (most recent call last):
  File "/venv/lib/python3.5/site-packages/IPython/core/interactiveshell.py", line 3265, in run_code
    exec(code_obj, self.user_global_ns, self.user_ns)
  File "<ipython-input-32-77bf6a4625f1>", line 1, in <module>
    hv.renderer('bokeh').static_html(hv.Violin(data=df, kdims='time_of_day', vdims='level').opts(inner='quartiles'))
  File "/venv/lib/python3.5/site-packages/holoviews/plotting/renderer.py", line 361, in static_html
    html = self.html(obj, fmt)
  File "/venv/lib/python3.5/site-packages/holoviews/plotting/renderer.py", line 284, in html
    plot, fmt =  self._validate(obj, fmt)
  File "/venv/lib/python3.5/site-packages/holoviews/plotting/renderer.py", line 220, in _validate
    plot = self.get_plot(obj, renderer=self, **kwargs)
  File "/venv/lib/python3.5/site-packages/holoviews/plotting/bokeh/renderer.py", line 134, in get_plot
    plot = super(BokehRenderer, self_or_cls).get_plot(obj, renderer, **kwargs)
  File "/venv/lib/python3.5/site-packages/holoviews/plotting/renderer.py", line 207, in get_plot
    plot.update(init_key)
  File "/venv/lib/python3.5/site-packages/holoviews/plotting/plot.py", line 595, in update
    return self.initialize_plot()
  File "/venv/lib/python3.5/site-packages/holoviews/plotting/bokeh/element.py", line 1049, in initialize_plot
    self._init_glyphs(plot, element, ranges, source)
  File "/venv/lib/python3.5/site-packages/holoviews/plotting/bokeh/element.py", line 1192, in _init_glyphs
    data, mapping, style = self.get_data(element, ranges, style)
  File "/venv/lib/python3.5/site-packages/holoviews/plotting/bokeh/stats.py", line 411, in get_data
    kde, segs, bars, scatter = self._kde_data(g, key, **kwargs)
  File "/venv/lib/python3.5/site-packages/holoviews/plotting/bokeh/stats.py", line 347, in _kde_data
    sidx = np.argmin(np.abs(xs-stat))
  File "/venv/lib/python3.5/site-packages/numpy/core/fromnumeric.py", line 1019, in argmin
    return _wrapfunc(a, 'argmin', axis=axis, out=out)
  File "/venv/lib/python3.5/site-packages/numpy/core/fromnumeric.py", line 57, in _wrapfunc
    return getattr(obj, method)(*args, **kwds)
ValueError: attempt to get argmin of an empty sequence

This also happens for inner='stick' but not for inner='box'

@Safrone
Copy link
Contributor Author

Safrone commented Jan 16, 2019

Still an issue for 'box'

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants