How can we use Plotly's config parameter to edit the hoverbar/modebar?

According to the plotly docs: https://plotly.com/python/configuration-options/ you can pass a config parameter to fig.show(). When I try to use fig.show(config=config) it pops out into a new browser tab. Is there a way to utilize the config parameter to update the graphs that streamlit displays?

Example:
config = {
‘toImageButtonOptions’: {
‘format’: ‘svg’, # one of png, svg, jpeg, webp
‘filename’: ‘custom_image’,
‘height’: 500,
‘width’: 700,
‘scale’: 1 # Multiply title/legend/axis/canvas sizes by this factor
}

fig = px.bar(x=[1, 2, 3], y=[1, 3, 1])

fig.show(config=config)

1 Like

I think I figured it out. I used this and it seems to be working:

st.plotly_chart(fig, use_container_width=False, **{‘config’: config})

4 Likes

Thanks. This was helpful.

FYI, since you are unpacking the dictionary anyway, you can just write:

st.plotly_chart(fig, use_container_width=False, config=config)
2 Likes