Hi there,
I was just recreating the steps from this tutorial Interactive annotations and shape drawing in plotly figures and Dash apps | Interactive image processing with scikit-image and Dash where I am interested in making annotations to images. I also had a look at Images in Python to achieve this. Since I am relatively new to Dash, I was just following along and playing with the content.
In the second example, the line:
fig.show(config={'modeBarButtonsToAdd': ['drawline', 'drawrect', 'eraseshape']})
is responsible for opening a new tab in my browser, allowing me to annotate the image with the tools ‘drawline’, ‘drawrect’ and ‘eraseshape’. This is nice, but I need more “stuff” around the figure, so the fig.show()
won’t help me further. Thus I added the figure to the layout. However, if I pass these buttons to the dcc.Graph() function (like in the first link that I provided):
dcc.Graph(
id='annotation_plane',
figure=fig,
config={'modeBarButtonsToAdd': ['drawline', 'drawrect', 'eraseshape']})
I get an error from dash, stating:
must provide button ‘name’ in button config
How could I add a name to the button? Where would I do this? I was already trying to provide a dict of buttons and their names
config={'modeBarButtonsToAdd': {'drawline' : 'draw_ln', 'drawrect': 'draw_rect', 'eraseshape': 'erase_shp'}}
resulting in the error, that a list
is required, not a dict
. Also, there is no parameter 'ButtonNames'
in the list of possible parameters.
How can I get this to work? Dash is just too good, but without this, I can’t really use it…
Thanks for your help and best regards,
Martin