Remove controls from plotly figure
I'm using plotly to create clickable images that are tightly arranged. For this I need to remove the plotly controls. This can be done by passing config={'displayModeBar': False} to plotly.show, but as this is not a figure property I'm not sure how to accomplish this when doing solara.FigurePlotly(fig).
7 Replies
@artursp. I don't think there's a way to do that using solara FigurePlotly component.
The displayModeBar is not part of the figure, it's changed in the render phase of Plotly. There's a hack in the end of this issue that may help you hacking solara rendering as well: https://github.com/plotly/plotly.py/issues/1074#issuecomment-663543409
GitHub
pass config options to FigureWidget · Issue #1074 · plotly/plotly.py
Previously I was able to do plotly.offline.plot(..., config={'showLink':False, 'displayModeBar':False}) Is it possible using the new FigureWidget ?
Good question. I see that the widget exposes a https://github.com/plotly/plotly.py/blob/95cc3d0dc6b3379d181e28ba90a0b708fad3bc40/packages/python/plotly/plotly/basewidget.py#L41 _config object, maybe this needs to be an argument to our plotly component?
packages/python/plotly/plotly/basewidget.py
line 41
Thanks, unfortunately a naive application does not work (bar still shows):
import plotly.graph_objects as go
fig = go.FigureWidget()
fig._config = fig._config | {'displayModeBar': False}
solara.FigurePlotly(fig)
Would there be another straight forward method for getting clickable (matplotlib) images?
One option is to hide it with CSS
plotly .modebar { display: none; }
Nice workaround @Gordon !
To configure the underlying widget, you can use the following pattern:
awesome, thanks!