Skip to content

Holoviews panels and axis sharing after plot update - datetime axis #7795

Description

ALL software version info

panel==1.6.1

Software Version Info
holoviews==1.20.1
bokeh==3.6.3
hvplot==-0.11.2

Description of expected behavior and the observed behavior

When two or more holoviews plots are on the same page and the axes are linked. If you change the view (for example with mouse scroll) on one, then updated the data and the plots, it returns an error. Steps are as follows:

  • Show two holoviews panes
  • Scroll to changes axes limits, both adjust as expected
  • Refresh the data and update the plots.

Complete, minimal, self-contained example code that reproduces the issue

import panel as pn
import pandas as pd
import hvplot.pandas
import holoviews as hv
import numpy as np
pn.extension('tabulator',sizing_mode='stretch_width')
hv.extension('bokeh', theme='dark')


class MREViewer(pn.viewable.Viewer):

    plot1 = pn.pane.HoloViews(sizing_mode='stretch_width')
    plot2 = pn.pane.HoloViews(sizing_mode='stretch_width')
    reload_data_button = pn.widgets.Button(name='Reload Data')

    @pn.depends('reload_data_button.clicks', watch=True,on_init=True)
    def update_plots(self):
        dates = pd.date_range('2021-01-01', periods=365)
        data = pd.DataFrame({'Date': dates, 'Value': np.random.randn(365).cumsum()})

        new_plot1 = data.hvplot(x='Date', y='Value', title='Plot 1')
        new_plot2 = data.hvplot(x='Date', y='Value', title='Plot 2')
        self.plot1.object = new_plot1
        self.plot2.object = new_plot2

    def __panel__(self):
        # Include the reload_data_button in the layout
        layout = pn.Column(self.reload_data_button, self.plot1, self.plot2)
        return layout

app = MREViewer()
app.servable()

Stack traceback and/or browser JavaScript console output

message: Message 'PATCH-DOC' content: {'events': [{'kind': 'MessageSent', 'msg_type': 'bokeh_event', 'msg_data': {'type': 'event', 'name': 'button_click', 'values': {'type': 'map', 'entries': [['model', {'id': 'p7196'}]]}}}]}
error: UFuncTypeError(<ufunc 'greater'>, (<class 'numpy.dtypes.DateTime64DType'>, <class 'numpy.dtypes._PyFloatDType'>, None))
numpy.exceptions.DTypePromotionError: The DType <class 'numpy.dtypes.DateTime64DType'> could not be promoted by <class 'numpy.dtypes._PyFloatDType'>. This means that no common DType exists for the given inputs. For example they cannot be stored in a single array unless the dtype is object. The full list of DTypes is: (<class 'numpy.dtypes.DateTime64DType'>, <class 'numpy.dtypes._PyFloatDType'>)

The above exception was the direct cause of the following exception:

...

if axis.start > axis.end:
^^^^^^^^^^^^^^^^^^^^^
numpy._core._exceptions._UFuncNoLoopError: ufunc 'greater' did not contain a loop with signature matching types (<class 'numpy.dtypes.DateTime64DType'>, <class 'numpy.dtypes._PyFloatDType'>) -> None

Screenshots or screencasts of the bug in action

Image

Image

After reload data clicked
Image

Traceback shown above

  • I may be interested in making a pull request to address this

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions