Web app with hvPlot

Solved!
Luis_PB
Level 2
Web app with hvPlot

Is there a way to create Web apps using the hvPlot?

0 Kudos
1 Solution
AlexT
Dataiker

Hi,
You in can include hvplot in Dash webapp for example:
YOu need to install dash/hvplot in the code env :

import dash
import dash_core_components as dcc
import dash_html_components as html
import pandas as pd
import hvplot.pandas
import holoviews as hv

from holoviews.plotting.plotly import PlotlyRenderer

# Enable the Plotly renderer for HoloViews
hv.extension('plotly')

# Sample data
df = pd.DataFrame({'x': [1, 2, 3, 4, 5], 'y': [2, 4, 1, 5, 3]})

# Create an hvplot figure
plot = df.hvplot.scatter(x='x', y='y', title='Scatter Plot')

# Convert the hvplot figure to a Plotly plot
plotly_plot = PlotlyRenderer.get_plot(plot).state


# Define the layout of the Dash app
app.layout = html.Div(children=[
    html.H1(children='Scatter Plot'),
    dcc.Graph(id='scatter-plot', figure=plotly_plot)
])



 

View solution in original post

1 Reply
AlexT
Dataiker

Hi,
You in can include hvplot in Dash webapp for example:
YOu need to install dash/hvplot in the code env :

import dash
import dash_core_components as dcc
import dash_html_components as html
import pandas as pd
import hvplot.pandas
import holoviews as hv

from holoviews.plotting.plotly import PlotlyRenderer

# Enable the Plotly renderer for HoloViews
hv.extension('plotly')

# Sample data
df = pd.DataFrame({'x': [1, 2, 3, 4, 5], 'y': [2, 4, 1, 5, 3]})

# Create an hvplot figure
plot = df.hvplot.scatter(x='x', y='y', title='Scatter Plot')

# Convert the hvplot figure to a Plotly plot
plotly_plot = PlotlyRenderer.get_plot(plot).state


# Define the layout of the Dash app
app.layout = html.Div(children=[
    html.H1(children='Scatter Plot'),
    dcc.Graph(id='scatter-plot', figure=plotly_plot)
])