Problem with Plot Annotations

I’ve just tried to add an annotation to an existing plot and got an error.

Here’s a demo of the problem using the code pasted directly from the Plot docs (which also fails to add the example Marker):

https://anvil.works/build#clone:RXD4SYR6TQFSJOIY=MEWJEHUXQVEQ3Y6UP3A6Q6W4

Hi @owen.campbell,

Here’s an updated version of your clone link with the annotation and marker working:

I updated the layout.annotations property to use the following syntax, as per the Plotly docs:

self.plot_1.layout.annotations = [
        dict(
          text = 'Simple annotation',
          x = 0,
          xref = 'paper',
          y = 0,
          yref = 'paper'
        )
    ]

Text and annotations in Python

Thank you!

My example was pasted directly from the code in https://anvil.works/docs/client/components/plots

I hadn’t thought of looking to see if that matches plotly’s docs!

Thanks for letting me know - we’ll get that updated :slight_smile:

1 Like