Is there a way to change the id of a plotly figure in python?
For example if I run this code taken from the plotly webpage:
import plotly.graph_objects as go
fig = go.Figure()
config = dict({'scrollZoom': True})
fig.add_trace(
go.Scatter(
x=[1, 2, 3],
y=[1, 3, 1]))
fig.show(config=config)
If I inspect the element I can see that the figure is in a div container with a strange id (cd3a3c26...
) .
How can I change this to my-figure
?
And is it possible to also change the div class?
Thank you for your help!
It's a bit of an old question, but starting on version
5.5.0
there is a way: plotly introduceddiv_id
argument to the html generation, where you can select the id of the div container:I don't think it's possible to change directly on
fig.show()
though. I also don't think it's possible to change the class directly. One possibility is to add "by hand" using text replacement and javascript:Results in: