4

There is an example about multiple annotations, it simply duplicate the go.layout.Annotation() to draw 2 arrows.

But I need to draw more than 100+ arrows, I don't know how. The go.layout.Annotation() is tuple type and accepts dict() for each arrow, is there any easy way to add more dict() to tuple() ?

Thank you.

1 Answer 1

12

I solved my own question.

fig.layout.annotations accepts list, parameters of each arrow is a dict(). So the idea is to create a list of many dict(), and then use fig.update_layout(annotations = list) to draw multiple arrows.

the dict() for each arrow looks like this:

arrow = go.layout.Annotation(dict(
                x= x_end,
                y= y_end,
                xref="x", yref="y",
                text="",
                showarrow=True,
                axref = "x", ayref='y',
                ax= x_start,
                ay= y_start,
                arrowhead = 3,
                arrowwidth=1.5,
                arrowcolor='rgb(255,51,0)',)
            )

the list for multiple arrows can be easily created like this:

list = list + [dict()]

Then, update the fig:

fig.update_layout(
annotations= list_of_all_arrows,)

If all arrows are in time series, this is the final result: enter image description here

Sign up to request clarification or add additional context in comments.

1 Comment

The problem of this method is that I had too many legends that I cannot easily turn on or turn off by one button.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.