plotly / plotly/plotly.py

modeBarButtonsToAdd doesn’t appear to be working as intended

Open
#2,981 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

bug P3
Dominant language
Python
Stars
18.8k
Forks
2.8k
Avg merge
16h 26m
Merged PRs (30d)
21

Description

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

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by running the provided Python reproduction with plotly.offline.plot and the modeBarButtonsToAdd configuration, comparing it with an empty button list. Trace the offline HTML generation and verify that the output renders successfully with the drawing buttons enabled; use the reported Python 3.7 and Plotly 4.14.1 environment when checking the behavior.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
data-visualization
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.