Web app with hvPlot

Luis Paulo
Luis Paulo Registered Posts: 6 ✭✭✭✭

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

Best Answer

  • Alexandru
    Alexandru Dataiker, Dataiku DSS Core Designer, Dataiku DSS ML Practitioner, Dataiku DSS Adv Designer, Registered Posts: 1,225 Dataiker
    edited July 17 Answer ✓

    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)
    ])
    
    



Setup Info
    Tags
      Help me…