I would like to plot an interactive Holoviews plot with streamlit.
Is this possible? If so, how can I can do this?
Here’s an example of generating a holoviews (bokeh) plot with hvplot. The example of the line_chart works, but displaying my interactive holoviews plot doesn’t work.
# import libraries
import streamlit as st
import numpy as np
import pandas as pd
import hvplot
import hvplot.pandas
import holoviews as hv
hv.extension('bokeh', logo=False)
# create sample data
@st.cache
def get_data():
return pd.DataFrame(data=np.random.normal(size=[50, 2]), columns=['col1', 'col2'])
df = get_data()
# streamlit plotting works
st.line_chart(df)
# creating a holoviews plot
nice_plot = df.hvplot(kind='scatter')
# this doesn't work unfortunately. How can i show 'nice_plot'
st.bokeh_chart(nice_plot)
@Adrien_Treuille thank you for that! I wonder if you all might be open to a top-level API call, such as st.hvplot(nice_plot) that automagically wraps hv.render in there? If so, I’m happy to write the PR that makes this happen.
Depending on how much code this turns out to be, though, a good strategy would be to send out working sketch of the solution in a PR with the WIP label, so we can discuss architecture there before you do too much coding. Up to you, though.
This is a great idea, but st.hvplot has a bit of a name conflict with the package hvplot. Perhaps st.hv would be enough?
For a more general solution, I just opened a new issue with the suggestion that streamlit look on objects for a particular method and use that if provided.
Thanks for stopping by! We use cookies to help us understand how you interact with our website.
By clicking “Accept all”, you consent to our use of cookies. For more information, please see our privacy policy.
Cookie settings
Strictly necessary cookies
These cookies are necessary for the website to function and cannot be switched off. They are usually only set in response to actions made by you which amount to a request for services, such as setting your privacy preferences, logging in or filling in forms.
Performance cookies
These cookies allow us to count visits and traffic sources so we can measure and improve the performance of our site. They help us understand how visitors move around the site and which pages are most frequently visited.
Functional cookies
These cookies are used to record your choices and settings, maintain your preferences over time and recognize you when you return to our website. These cookies help us to personalize our content for you and remember your preferences.
Targeting cookies
These cookies may be deployed to our site by our advertising partners to build a profile of your interest and provide you with content that is relevant to you, including showing you relevant ads on other websites.