plotly.py
plotly.py copied to clipboard
modeBarButtonsToAdd doesn’t appear to be working as intended
Using "modeBarButtonsToAdd" to add buttons for interactive annotations and shape drawing in plotly figures, it prevents the HTML plot to be shown at all with plotly.offline rendering!
import plotly.offline as offline
import plotly.express as px
df = px.data.iris()
fig = px.scatter(df, x='petal_width', y='sepal_length', color='species')
fig.update_layout(
dragmode='drawopenpath',
newshape_line_color='cyan',
title_text='Draw a path to separate versicolor and virginica'
)
config = dict({'scrollZoom': True,'displaylogo': False, 'modeBarButtonsToAdd':['drawline','drawopenpath','drawcircle','drawrect','eraseshape']})
offline.plot(fig,
auto_open=True, image = None, config =config,
filename='./foo.html', include_plotlyjs='directory')
If the 'modeBarButtonsToAdd':[ ] is emptied, the HTML is correctly rendered again. Any idea with this weird behaviour? Please, see also https://eoss-image-processing.github.io/2020/05/06/shape-drawing.html
Environment: Python 3.7 Plotly 4.14.1 dash 1.18.1