✊🏿 Black Lives Matter. Please consider donating to Black Girls Code today.
⚡️ Concerned about the grid? Kyle Baranko teaches how to predicting peak loads using XGBoost. Register for the August webinar!

Arrow heads at the direction of line (arrows)

Hi team,

I created the graph below but I want to add arrowheads at the end of the lines in the same direction as the lines.

Can you please help me with that?

fig.add_trace(go.Scatter(x=df1[‘Week_x’], y=df1[‘Week_y’], mode=‘lines’, marker=dict(symbol=“line-ne”),line=dict(color=‘red’,width=2), name=‘1 week’))

fig.add_trace(go.Scatter(x=df1[‘Month_x’], y=df1[‘Month_y’], mode=‘lines’, marker=dict(symbol=“diamond-dot”),line=dict(color=‘royalblue’,width=2), name=‘1 month’))
fig.add_trace(go.Scatter(x=df1[‘3Month_x’], y=df1[‘3Month_y’], mode=‘lines’, marker=dict(symbol=“diamond-dot”),line=dict(color=‘green’,width=2), name=‘3 months’))

fig.add_trace(go.Scatter(x=df1[‘6Month_x’], y=df1[‘6Month_y’], mode=‘lines’, marker=dict(symbol=“diamond-dot”),line=dict(color=‘purple’,width=2), name=‘6 months’))

fig.add_trace(go.Scatter(x=df1[‘std_week_x’], y=df1[‘std_week_y’], mode=‘markers’, marker=dict(symbol=“diamond-dot”),line=dict(color=‘red’,width=2), name=‘1 week std’))

fig.add_trace(go.Scatter(x=df1[‘std_month_x’], y=df1[‘std_month_y’], mode=‘markers’, marker=dict(symbol=“diamond-dot”),line=dict(color=‘royalblue’,width=2), name=‘1 month std’))

fig.add_trace(go.Scatter(x=df1[‘std_3month_x’], y=df1[‘std_3month_y’], mode=‘markers’, marker=dict(symbol=“diamond-dot”),line=dict(color=‘green’,width=2), name=‘3 months std’))

fig.add_trace(go.Scatter(x=df1[‘std_6month_x’], y=df1[‘std_6month_y’], mode=‘markers’, marker=dict(symbol=“diamond-dot”),line=dict(color=‘purple’,width=2), name=‘6 months std’))

Thank you,

Hi @vgelis, welcome to the forum! You could add an annotation with no text to display an arrow, see https://plot.ly/python/text-and-annotations/#simple-annotation

I read about the annotation you cited (and multiple annotations), but I’m unable to find the answer for the following problem.
I want to plot arrows from (0,0) to (1,2), etc, about 30 arrows.
How can I achieve it?

It’s been some time already, but I had this problem myself and figured how to solve it with @Emmanuelle 's tip:

import plotly.graph_objects as go

fig = go.Figure()

  x=30,  # arrows' head
  y=30,  # arrows' head
  ax=40,  # arrows' tail
  ay=40,  # arrows' tail
  text='',  # if you want only the arrow

You can see what each parameter does in the documentation: https://plotly.com/python-api-reference/generated/plotly.graph_objects.Figure.html#id0

Hope it helps