I am trying to create two buttons on a plotly graph object to display or not an image but just the trace move not the image. I would like to display or not a background image.
Here the code
@hierophant
To get your button work, first of all you should decide what you intend to change with each button:
if only a trace attribute(s), then use the method restyle;
if only a layout attribute(s), use the method relayout;
if both trace, and layout attributes, use the method update.
From your code it is obvious that a layout image is added to layout. Hence in the button definitin you will call the method=βrelayoutβ.
help(go.Layout)
lists the layout attributes/properties. Among them is the list images, i.e. we can add more than a single image to a figure layout.
In your case this list contains only an image, as images[0]. For this image a button changes the attribute visible from True to False. Hence the code to make your image visible and invisible is as follows: