holoviz / holoviews

With Holoviews, your data visualizes itself.
https://holoviews.org
BSD 3-Clause "New" or "Revised" License
2.66k stars 396 forks source link

Continous Bars no longer working #6300

Closed MarcSkovMadsen closed 1 day ago

MarcSkovMadsen commented 1 week ago

I'm trying to make a bar plot with hvplot using timeseries data. I would like to give positive values a green bar color and negative values a red bar color to make it very clear where the changes are positive and negative.

I've tried formatting my time as strings, ints and datatimes. I've tried arranging my data and using the by argument. I've tried setting the color as a list of colors. But I cannot achieve this either because it errors or it does not display as I want.

A workaround would be highly appreciated as this is the most used kindof plot in my domain.

Reproducible Example

I believe the below is a bug.

import panel as pn
import hvplot.pandas
from datetime import datetime
pn.extension()

KIND="bar"

positive_values = pd.DataFrame({
    "time": [datetime(year,1,1) for year in range(2025, 2033)],
    "value": list(range(1,9)),
})
neg_start=2024
negative_values = pd.DataFrame({
    "time": [datetime(2024,1,1)],
    "value": [-1]
})
pos_plot = positive_values.hvplot(x="time.year", y="value", color="green", kind=KIND)
neg_plot = negative_values.hvplot(x="time.year", y="value", color="red", kind=KIND)

plot = neg_plot*pos_plot

pn.panel(plot).servable()
Traceback (most recent call last):
  File "/home/jovyan/repos/mt-pm-reporting/.venv/lib/python3.11/site-packages/panel/reactive.py", line 432, in _change_coroutine
    self._change_event(doc)
  File "/home/jovyan/repos/mt-pm-reporting/.venv/lib/python3.11/site-packages/panel/reactive.py", line 450, in _change_event
    self._process_events(events)
  File "/home/jovyan/repos/mt-pm-reporting/.venv/lib/python3.11/site-packages/panel/reactive.py", line 1332, in _process_events
    self._update_selection(events.pop('indices'))
  File "/home/jovyan/repos/mt-pm-reporting/.venv/lib/python3.11/site-packages/panel/widgets/tables.py", line 1641, in _update_selection
    self.selection = indices
    ^^^^^^^^^^^^^^
  File "/home/jovyan/repos/mt-pm-reporting/.venv/lib/python3.11/site-packages/param/parameterized.py", line 528, in _f
    instance_param.__set__(obj, val)
  File "/home/jovyan/repos/mt-pm-reporting/.venv/lib/python3.11/site-packages/param/parameterized.py", line 530, in _f
    return f(self, obj, val)
           ^^^^^^^^^^^^^^^^^
  File "/home/jovyan/repos/mt-pm-reporting/.venv/lib/python3.11/site-packages/param/parameterized.py", line 1553, in __set__
    obj.param._call_watcher(watcher, event)
  File "/home/jovyan/repos/mt-pm-reporting/.venv/lib/python3.11/site-packages/param/parameterized.py", line 2526, in _call_watcher
    self_._execute_watcher(watcher, (event,))
  File "/home/jovyan/repos/mt-pm-reporting/.venv/lib/python3.11/site-packages/param/parameterized.py", line 2506, in _execute_watcher
    watcher.fn(*args, **kwargs)
  File "/home/jovyan/repos/mt-pm-reporting/.venv/lib/python3.11/site-packages/param/depends.py", line 108, in cb
    return func(*args, **dep_kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/jovyan/repos/mt-pm-reporting/.venv/lib/python3.11/site-packages/param/reactive.py", line 594, in wrapped
    return eval_fn()(*combined_args, **combined_kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/jovyan/repos/mt-pm-reporting/src/mt_pm_reporting/reporting/ui/components/widgets.py", line 380, in _update_selection
    self.value = self.object.loc[selection[0], "key"]
    ^^^^^^^^^^
  File "/home/jovyan/repos/mt-pm-reporting/.venv/lib/python3.11/site-packages/param/parameterized.py", line 528, in _f
    instance_param.__set__(obj, val)
  File "/home/jovyan/repos/mt-pm-reporting/.venv/lib/python3.11/site-packages/param/parameterized.py", line 530, in _f
    return f(self, obj, val)
           ^^^^^^^^^^^^^^^^^
  File "/home/jovyan/repos/mt-pm-reporting/.venv/lib/python3.11/site-packages/param/parameterized.py", line 1553, in __set__
    obj.param._call_watcher(watcher, event)
  File "/home/jovyan/repos/mt-pm-reporting/.venv/lib/python3.11/site-packages/param/parameterized.py", line 2526, in _call_watcher
    self_._execute_watcher(watcher, (event,))
  File "/home/jovyan/repos/mt-pm-reporting/.venv/lib/python3.11/site-packages/param/parameterized.py", line 2506, in _execute_watcher
    watcher.fn(*args, **kwargs)
  File "/home/jovyan/repos/mt-pm-reporting/.venv/lib/python3.11/site-packages/param/depends.py", line 108, in cb
    return func(*args, **dep_kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/jovyan/repos/mt-pm-reporting/.venv/lib/python3.11/site-packages/param/reactive.py", line 594, in wrapped
    return eval_fn()(*combined_args, **combined_kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/jovyan/repos/mt-pm-reporting/src/mt_pm_reporting/reporting/ui/components/base.py", line 41, in update_other
    setattr(other, other_name, value)
  File "/home/jovyan/repos/mt-pm-reporting/.venv/lib/python3.11/site-packages/param/parameterized.py", line 528, in _f
    instance_param.__set__(obj, val)
  File "/home/jovyan/repos/mt-pm-reporting/.venv/lib/python3.11/site-packages/param/parameterized.py", line 530, in _f
    return f(self, obj, val)
           ^^^^^^^^^^^^^^^^^
  File "/home/jovyan/repos/mt-pm-reporting/.venv/lib/python3.11/site-packages/param/parameterized.py", line 1553, in __set__
    obj.param._call_watcher(watcher, event)
  File "/home/jovyan/repos/mt-pm-reporting/.venv/lib/python3.11/site-packages/param/parameterized.py", line 2526, in _call_watcher
    self_._execute_watcher(watcher, (event,))
  File "/home/jovyan/repos/mt-pm-reporting/.venv/lib/python3.11/site-packages/param/parameterized.py", line 2506, in _execute_watcher
    watcher.fn(*args, **kwargs)
  File "/home/jovyan/repos/mt-pm-reporting/.venv/lib/python3.11/site-packages/param/parameterized.py", line 784, in _sync_caller
    return function()
           ^^^^^^^^^^
  File "/home/jovyan/repos/mt-pm-reporting/.venv/lib/python3.11/site-packages/param/depends.py", line 53, in _depends
    return func(*args, **kw)
           ^^^^^^^^^^^^^^^^^
  File "/home/jovyan/repos/mt-pm-reporting/src/mt_pm_reporting/reporting/ui/components/stores.py", line 119, in _update_total_change_by_time
    self.total_change_by_time = get_change_by_time(
    ^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/jovyan/repos/mt-pm-reporting/.venv/lib/python3.11/site-packages/param/parameterized.py", line 528, in _f
    instance_param.__set__(obj, val)
  File "/home/jovyan/repos/mt-pm-reporting/.venv/lib/python3.11/site-packages/param/parameterized.py", line 530, in _f
    return f(self, obj, val)
           ^^^^^^^^^^^^^^^^^
  File "/home/jovyan/repos/mt-pm-reporting/.venv/lib/python3.11/site-packages/param/parameterized.py", line 1553, in __set__
    obj.param._call_watcher(watcher, event)
  File "/home/jovyan/repos/mt-pm-reporting/.venv/lib/python3.11/site-packages/param/parameterized.py", line 2526, in _call_watcher
    self_._execute_watcher(watcher, (event,))
  File "/home/jovyan/repos/mt-pm-reporting/.venv/lib/python3.11/site-packages/param/parameterized.py", line 2506, in _execute_watcher
    watcher.fn(*args, **kwargs)
  File "/home/jovyan/repos/mt-pm-reporting/.venv/lib/python3.11/site-packages/panel/param.py", line 897, in _replace_pane
    self._update_inner(new_object)
  File "/home/jovyan/repos/mt-pm-reporting/.venv/lib/python3.11/site-packages/panel/pane/base.py", line 700, in _update_inner
    self._inner_layout[:] = [self._pane]
    ~~~~~~~~~~~~~~~~~~^^^
  File "/home/jovyan/repos/mt-pm-reporting/.venv/lib/python3.11/site-packages/panel/layout/base.py", line 417, in __setitem__
    self.objects = new_objects
    ^^^^^^^^^^^^
  File "/home/jovyan/repos/mt-pm-reporting/.venv/lib/python3.11/site-packages/param/parameterized.py", line 528, in _f
    instance_param.__set__(obj, val)
  File "/home/jovyan/repos/mt-pm-reporting/.venv/lib/python3.11/site-packages/param/parameterized.py", line 530, in _f
    return f(self, obj, val)
           ^^^^^^^^^^^^^^^^^
  File "/home/jovyan/repos/mt-pm-reporting/.venv/lib/python3.11/site-packages/param/parameterized.py", line 1553, in __set__
    obj.param._call_watcher(watcher, event)
  File "/home/jovyan/repos/mt-pm-reporting/.venv/lib/python3.11/site-packages/param/parameterized.py", line 2526, in _call_watcher
    self_._execute_watcher(watcher, (event,))
  File "/home/jovyan/repos/mt-pm-reporting/.venv/lib/python3.11/site-packages/param/parameterized.py", line 2506, in _execute_watcher
    watcher.fn(*args, **kwargs)
  File "/home/jovyan/repos/mt-pm-reporting/.venv/lib/python3.11/site-packages/panel/reactive.py", line 375, in _param_change
    self._apply_update(named_events, properties, model, ref)
  File "/home/jovyan/repos/mt-pm-reporting/.venv/lib/python3.11/site-packages/panel/reactive.py", line 303, in _apply_update
    self._update_model(events, msg, root, model, doc, comm)
  File "/home/jovyan/repos/mt-pm-reporting/.venv/lib/python3.11/site-packages/panel/layout/base.py", line 106, in _update_model
    children, old_children = self._get_objects(model, old, doc, root, comm)
                             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/jovyan/repos/mt-pm-reporting/.venv/lib/python3.11/site-packages/panel/layout/base.py", line 167, in _get_objects
    child = pane._get_model(doc, root, model, comm)
            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/jovyan/repos/mt-pm-reporting/.venv/lib/python3.11/site-packages/panel/layout/base.py", line 185, in _get_model
    objects, _ = self._get_objects(model, [], doc, root, comm)
                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/jovyan/repos/mt-pm-reporting/.venv/lib/python3.11/site-packages/panel/layout/base.py", line 167, in _get_objects
    child = pane._get_model(doc, root, model, comm)
            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/jovyan/repos/mt-pm-reporting/.venv/lib/python3.11/site-packages/panel/pane/holoviews.py", line 429, in _get_model
    plot = self._render(doc, comm, root)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/jovyan/repos/mt-pm-reporting/.venv/lib/python3.11/site-packages/panel/pane/holoviews.py", line 525, in _render
    return renderer.get_plot(self.object, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/jovyan/repos/mt-pm-reporting/.venv/lib/python3.11/site-packages/holoviews/plotting/bokeh/renderer.py", line 68, in get_plot
    plot = super().get_plot(obj, doc, renderer, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/jovyan/repos/mt-pm-reporting/.venv/lib/python3.11/site-packages/holoviews/plotting/renderer.py", line 239, in get_plot
    plot.update(init_key)
  File "/home/jovyan/repos/mt-pm-reporting/.venv/lib/python3.11/site-packages/holoviews/plotting/plot.py", line 956, in update
    return self.initialize_plot()
           ^^^^^^^^^^^^^^^^^^^^^^
  File "/home/jovyan/repos/mt-pm-reporting/.venv/lib/python3.11/site-packages/holoviews/plotting/bokeh/element.py", line 3339, in initialize_plot
    child = subplot.initialize_plot(ranges, plot, plots)
            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/jovyan/repos/mt-pm-reporting/.venv/lib/python3.11/site-packages/holoviews/plotting/bokeh/element.py", line 2130, in initialize_plot
    self._init_glyphs(plot, element, ranges, source)
  File "/home/jovyan/repos/mt-pm-reporting/.venv/lib/python3.11/site-packages/holoviews/plotting/bokeh/element.py", line 2046, in _init_glyphs
    with abbreviated_exception():
  File "/home/jovyan/repos/mt-pm-reporting/.venv/lib/python3.11/site-packages/holoviews/core/options.py", line 222, in __exit__
    raise AbbreviatedException(etype, value, traceback)
holoviews.core.options.AbbreviatedException: RuntimeError: 

Expected width to reference fields in the supplied data source.

When a 'source' argument is passed to a glyph method, values that are sequences
(like lists or arrays) must come from references to data columns in the source.

For instance, as an example:

    source = ColumnDataSource(data=dict(x=a_list, y=an_array))

    p.circle(x='x', y='y', source=source, ...) # pass column names and a source

Alternatively, *all* data sequences may be provided as literals as long as a
source is *not* provided:

    p.circle(x=a_list, y=an_array, ...)  # pass actual sequences and no source

As my data is dynamically generated, I might have 0, 1 or many positive values. I should be able to handle these situations. I had something working for all situations but 1 positive value. But after upgrading my environment everything stopped working.

With the old environment I believe there was a problem here

image

The problem was that the case when xvals consists of 1 element is not handled well. Now I don't know. The problem is the stack trace does not give me hints of the problem that I can understand.

If you change KIND to "scatter" it does not raise an exception.

image

MarcSkovMadsen commented 1 week ago
$ uv pip show holoviews hvplot bokeh numpy pandas
Name: bokeh
Version: 3.4.2
Location: /home/jovyan/repos/mt-pm-reporting/.venv/lib/python3.11/site-packages
Requires: contourpy, jinja2, numpy, packaging, pandas, pillow, pyyaml, tornado, xyzservices
Required-by: holoviews, hvplot, panel
---
Name: holoviews
Version: 1.19.0
Location: /home/jovyan/repos/mt-pm-reporting/.venv/lib/python3.11/site-packages
Requires: bokeh, colorcet, numpy, packaging, pandas, panel, param, pyviz-comms
Required-by: hvplot
---
Name: hvplot
Version: 0.10.0
Location: /home/jovyan/repos/mt-pm-reporting/.venv/lib/python3.11/site-packages
Requires: bokeh, colorcet, holoviews, numpy, packaging, pandas, panel, param
Required-by: mt-pm-reporting
---
Name: numpy
Version: 2.0.0
Location: /home/jovyan/repos/mt-pm-reporting/.venv/lib/python3.11/site-packages
Requires:
Required-by: bokeh, contourpy, holoviews, hvplot, mt-pm-reporting, pandas, pandas-stubs, pandera, pyarrow, sycamore
---
Name: pandas
Version: 2.2.2
Location: /home/jovyan/repos/mt-pm-reporting/.venv/lib/python3.11/site-packages
Requires: numpy, python-dateutil, pytz, tzdata
Required-by: analytics-workspace, bokeh, holoviews, hvplot, mt-data-engineering, pandera, panel

I've also tried downgrading numpy to 1.26.1. Does not change anything for me. I've also tried downgrading bokeh to 3.4.1. Does not change anything for me.

MarcSkovMadsen commented 1 week ago

Actually neither of the continuous examples from the Bars documentation works for me now.

https://holoviews.org/reference/elements/bokeh/Bars.html

from datetime import datetime

import holoviews as hv
import hvplot.pandas
import pandas as pd
import panel as pn

pn.extension()

data = pd.DataFrame({"x": [0, 1, 5], "y": [0, 2, 10]})

pn.panel(hv.Bars(data, ["x"], ["y"])).servable()

data = pd.DataFrame({"x": pd.date_range("2017-01-01", "2017-01-03"), "y": [0, 2, -1]})
pn.panel(hv.Bars(data, ["x"], ["y"])).servable()

image

hoxbro commented 1 week ago

I don't have any problem with your last example (though I'm running on main on a couple of repos) image

Seems like a bad solve. Can you report what you see with hv.show_versions() in your environment?

MarcSkovMadsen commented 1 week ago

Python : 3.11.6 | packaged by conda-forge | (main, Oct 3 2023, 10:40:35) [GCC 12.3.0] Operating system : Linux-5.15.0-1064-azure-x86_64-with-glibc2.35 Panel comms : default

holoviews : 1.19.0

bokeh : 3.4.2 colorcet : 3.1.0 cudf : - dask : - datashader : - geoviews : - hvplot : 0.10.0 ibis-framework : - IPython : - jupyter_bokeh : - jupyterlab : - matplotlib : - networkx : - notebook : - numba : - numpy : 1.26.4 pandas : 2.2.2 panel : 1.4.4 param : 2.1.1 pillow : 10.3.0 plotly : - pyarrow : 16.1.0 pyviz_comms : 3.0.2 scikit-image : - scipy : - spatialpandas : - streamz : - tsdownsample : - xarray : - None

hoxbro commented 1 week ago

Just created a new environment, still don't see you last problem. Can you try serving the app with python -m panel serve file.py?

Python              :  3.11.9 | packaged by conda-forge | (main, Apr 19 2024, 18:36:13) [GCC 12.3.0]
Operating system    :  Linux-6.9.3-76060903-generic-x86_64-with-glibc2.35
Panel comms         :  default

holoviews           :  1.19.0

bokeh               :  3.4.2
colorcet            :  3.1.0
cudf                :  -
dask                :  -
datashader          :  -
geoviews            :  -
hvplot              :  -
ibis-framework      :  -
IPython             :  -
jupyter_bokeh       :  -
jupyterlab          :  -
matplotlib          :  3.8.4
networkx            :  -
notebook            :  -
numba               :  -
numpy               :  2.0.0
pandas              :  2.2.2
panel               :  1.4.4
param               :  2.1.1
pillow              :  10.3.0
plotly              :  -
pyarrow             :  -
pyviz_comms         :  3.0.2
scikit-image        :  -
scipy               :  -
spatialpandas       :  -
streamz             :  -
tsdownsample        :  -
xarray              :  -
MarcSkovMadsen commented 1 week ago

Hmm. I tried installing without using uv - just using plain pip.

Then I get back to my original problem

import panel as pn
import hvplot.pandas
from datetime import datetime
pn.extension()

KIND="bar"

positive_values = pd.DataFrame({
    "time": [datetime(year,1,1) for year in range(2025, 2033)],
    "value": list(range(1,9)),
})
neg_start=2024
negative_values = pd.DataFrame({
    "time": [datetime(2024,1,1)],
    "value": [-1]
})
pos_plot = positive_values.hvplot(x="time.year", y="value", color="green", kind=KIND)
neg_plot = negative_values.hvplot(x="time.year", y="value", color="red", kind=KIND)

plot = neg_plot*pos_plot

pn.panel(plot).servable()
ValueError: zero-size array to reduction operation minimum which has no identity

Traceback (most recent call last):
  File "/home/jovyan/repos/mt-pm-reporting/.venv/lib/python3.11/site-packages/panel/io/handlers.py", line 389, in run
    exec(self._code, module.__dict__)
  File "/home/jovyan/repos/mt-pm-reporting/script.py", line 24, in <module>
    pn.panel(plot).servable()
  File "/home/jovyan/repos/mt-pm-reporting/.venv/lib/python3.11/site-packages/panel/viewable.py", line 394, in servable
    self.server_doc(title=title, location=location) # type: ignore
    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/jovyan/repos/mt-pm-reporting/.venv/lib/python3.11/site-packages/panel/viewable.py", line 1001, in server_doc
    model = self.get_root(doc)
            ^^^^^^^^^^^^^^^^^^
  File "/home/jovyan/repos/mt-pm-reporting/.venv/lib/python3.11/site-packages/panel/pane/base.py", line 420, in get_root
    root_view, root = self._get_root_model(doc, comm, preprocess)
                      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/jovyan/repos/mt-pm-reporting/.venv/lib/python3.11/site-packages/panel/pane/base.py", line 349, in _get_root_model
    root = self.layout._get_model(doc, comm=comm)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/jovyan/repos/mt-pm-reporting/.venv/lib/python3.11/site-packages/panel/layout/base.py", line 185, in _get_model
    objects, _ = self._get_objects(model, [], doc, root, comm)
                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/jovyan/repos/mt-pm-reporting/.venv/lib/python3.11/site-packages/panel/layout/base.py", line 167, in _get_objects
    child = pane._get_model(doc, root, model, comm)
            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/jovyan/repos/mt-pm-reporting/.venv/lib/python3.11/site-packages/panel/pane/holoviews.py", line 429, in _get_model
    plot = self._render(doc, comm, root)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/jovyan/repos/mt-pm-reporting/.venv/lib/python3.11/site-packages/panel/pane/holoviews.py", line 525, in _render
    return renderer.get_plot(self.object, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/jovyan/repos/mt-pm-reporting/.venv/lib/python3.11/site-packages/holoviews/plotting/bokeh/renderer.py", line 68, in get_plot
    plot = super().get_plot(obj, doc, renderer, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/jovyan/repos/mt-pm-reporting/.venv/lib/python3.11/site-packages/holoviews/plotting/renderer.py", line 239, in get_plot
    plot.update(init_key)
  File "/home/jovyan/repos/mt-pm-reporting/.venv/lib/python3.11/site-packages/holoviews/plotting/plot.py", line 956, in update
    return self.initialize_plot()
           ^^^^^^^^^^^^^^^^^^^^^^
  File "/home/jovyan/repos/mt-pm-reporting/.venv/lib/python3.11/site-packages/holoviews/plotting/bokeh/element.py", line 3339, in initialize_plot
    child = subplot.initialize_plot(ranges, plot, plots)
            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/jovyan/repos/mt-pm-reporting/.venv/lib/python3.11/site-packages/holoviews/plotting/bokeh/element.py", line 2130, in initialize_plot
    self._init_glyphs(plot, element, ranges, source)
  File "/home/jovyan/repos/mt-pm-reporting/.venv/lib/python3.11/site-packages/holoviews/plotting/bokeh/element.py", line 2030, in _init_glyphs
    data, mapping, style = self.get_data(element, ranges, style)
                           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/jovyan/repos/mt-pm-reporting/.venv/lib/python3.11/site-packages/holoviews/plotting/bokeh/chart.py", line 931, in get_data
    width = np.min(width)
            ^^^^^^^^^^^^^
  File "/home/jovyan/repos/mt-pm-reporting/.venv/lib/python3.11/site-packages/numpy/_core/fromnumeric.py", line 3042, in min
    return _wrapreduction(a, np.minimum, 'min', axis, None, out,
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/jovyan/repos/mt-pm-reporting/.venv/lib/python3.11/site-packages/numpy/_core/fromnumeric.py", line 86, in _wrapreduction
    return ufunc.reduce(obj, axis, dtype, out, **passkwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
ValueError: zero-size array to reduction operation minimum which has no identity

I will close a new one focusing on that one.

hoxbro commented 1 week ago

I will fix that right now.

MarcSkovMadsen commented 1 week ago

I will keep this one open then.

MarcSkovMadsen commented 1 week ago

For future reference. I could use the color argument to hvplot. Just not providing a list. But referencing a column

from datetime import datetime

import holoviews as hv
import hvplot.pandas
import pandas as pd
import panel as pn

pn.extension()

KIND="bar"

data = pd.DataFrame({
    "time": [datetime(year,1,1) for year in range(2025, 2033)],
    "value": list(range(-5,3)),
})
data["color"]="green"
data.loc[data.value<0, "color"]="red"
plot = data.hvplot(x="time.year", y="value", color="color", kind=KIND)

pn.panel(plot).servable()

image