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

rasterize with time series data fails for plotly and matplotlib #6089

Open
buckeye17 opened this issue Jan 31, 2024 · 2 comments · May be fixed by #6103
Open

rasterize with time series data fails for plotly and matplotlib #6089

buckeye17 opened this issue Jan 31, 2024 · 2 comments · May be fixed by #6103
Labels
tag: backend: mpl tag: backend: plotly type: bug Something isn't correct or isn't working

Comments

@buckeye17
Copy link

buckeye17 commented Jan 31, 2024

ALL software version info

(this library, plus any other relevant software, e.g. bokeh, python, notebook, OS, browser, etc)

Windows 10
VSCode 1.85.2
Python 3.9.13

bokeh 3.3.4 Interactive plots and applications in the browser from Python
dash 2.14.2 A Python framework for building reactive web-apps. Developed by Plotly.
dash-bootstrap-components 1.5.0 Bootstrap themed components for use in Plotly Dash
dash-core-components 2.0.0 Core component suite for Dash
dash-html-components 2.0.0 Vanilla HTML components for Dash
datashader 0.16.0 Data visualization toolchain based on aggregating into a grid
holoviews 1.18.1 Stop plotting your data - annotate your data and let it visualize itself.
jupyter-bokeh 3.0.7 A Jupyter extension for rendering Bokeh content.
jupyter-client 8.6.0 Jupyter protocol implementation and client libraries
jupyter-core 5.5.1 Jupyter core package. A base package on which Jupyter projects rely.
jupyterlab-widgets 3.0.9 Jupyter interactive widgets for JupyterLab
numpy 1.26.2 Fundamental package for array computing in Python
pandas 2.1.4 Powerful data structures for data analysis, time series, and statistics
plotly 5.18.0 An open-source, interactive data visualization library for Python

Description of expected behavior and the observed behavior

To visualize long time series data with Datashader in Dash web app. Note that in a Jupyter notebook, the visualization works without the rasterize() wrapper. And the Dash web app graph works if the X-axis is changed from datetimes to integers. So it seems that rasterize() does not work with a time series axis sent through to_dash().

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

There is an example here:
https://community.plotly.com/t/dash-holoviews-datashader-datetime-axes-y-u-no-work/54241

Stack traceback and/or browser JavaScript console output

Traceback (most recent call last):
  File "c:\Users\613186\git_projects\Sensor-Analytics-Pipeline\ui\app.py", line 172, in update_graphs
    components = to_dash(app, [scatter], reset_button=True)
  File "C:\Users\613186\git_projects\Sensor-Analytics-Pipeline\.venv\lib\site-packages\holoviews\plotting\plotly\dash.py", line 377, in to_dash
    plot = PlotlyRenderer.get_plot(hvobj)
  File "C:\Users\613186\git_projects\Sensor-Analytics-Pipeline\.venv\lib\site-packages\holoviews\plotting\renderer.py", line 240, in get_plot
    plot.update(init_key)
  File "C:\Users\613186\git_projects\Sensor-Analytics-Pipeline\.venv\lib\site-packages\holoviews\plotting\plot.py", line 955, in update
    return self.initialize_plot()
  File "C:\Users\613186\git_projects\Sensor-Analytics-Pipeline\.venv\lib\site-packages\holoviews\plotting\plotly\element.py", line 130, in initialize_plot
    fig = self.generate_plot(self.keys[-1], ranges, is_geo=is_geo)
  File "C:\Users\613186\git_projects\Sensor-Analytics-Pipeline\.venv\lib\site-packages\holoviews\plotting\plotly\element.py", line 185, in generate_plot
    data = self.get_data(element, ranges, style, is_geo=is_geo)
  File "C:\Users\613186\git_projects\Sensor-Analytics-Pipeline\.venv\lib\site-packages\holoviews\plotting\plotly\raster.py", line 50, in get_data
    x0, y0 = l+dx/2., b+dy/2.
numpy.core._exceptions._UFuncBinaryResolutionError: ufunc 'add' cannot use operands with types dtype('<M8[ns]') and dtype('float64')
@hoxbro
Copy link
Member

hoxbro commented Jan 31, 2024

This seems to be a problem without dash, both with matplotlib and plotly backend.

import holoviews as hv
from holoviews.operation.datashader import rasterize
import numpy as np
import pandas as pd

hv.extension("plotly")

X = pd.date_range(start="1/1/2018", end="1/08/2018", periods=100)
Y = np.linspace(1, 100, 100)
Z = np.random.randn(100, 100)

rasterize(hv.QuadMesh((X, Y, Z)))

@hoxbro hoxbro transferred this issue from holoviz/datashader Jan 31, 2024
@hoxbro hoxbro added type: bug Something isn't correct or isn't working tag: backend: mpl tag: backend: plotly labels Jan 31, 2024
@hoxbro hoxbro changed the title hv.Curve -> rasterize -> to_dash with time series data fails rasterize with time series data fails for plotly and matplotlib Jan 31, 2024
@jbednar
Copy link
Member

jbednar commented Feb 3, 2024

Datashader cannot natively accept datetime types, so I believe the HoloViews Bokeh backend converts the data to an integer format before sending it out for rendering. So presumably that same code would need to be applied to the other backends as well, hopefully in a way that can be shared between them.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
tag: backend: mpl tag: backend: plotly type: bug Something isn't correct or isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants