Plot arrow ( given direction - angle) at given coordinates

Is it possible to have a plot like the following given the data
I am not looking for a quiver plot or annotations ( unless these type can achieve the following )

The closest example I found is python - Line plot with arrows in matplotlib - Stack Overflow
but still unable to make it because I am missing some understanding of the U V components. Please suggest

Hi @yogi_dhiman ,

if you do not mind the circles instead of arrowheads, you could do something like this:

import plotly.graph_objects as go
import numpy as np

# set data
x = np.asarray([0,1,2,3,4,5,6])
y = np.asarray([0,1,2,3,4,5,6])
a = np.asarray([55,-20,34,22,76,-20,-80])
length = 1

# calculate coordinates of second vector point
dx = x + np.cos(np.radians(a)) * length
dy = y + np.sin(np.radians(a)) * length

# add start and end points to array
xx = np.c_[x, dx]
yy = np.c_[y, dy]

# create figure
fig = go.Figure()

# add traces to figure
for x, y in zip(xx, yy):
    fig.add_scatter(x=x, y=y, mode='markers+lines', marker={'size': [0,10]})

# update figure layout
fig.update_layout({'xaxis': {'range': [0,7]}, 'yaxis': {'range': [0,7]}, 'width': 800, 'height': 800})

which produces this:

3 Likes

This is exactly what I wanted. You understood the problem precisely.

AIMPED wonder if this can be done without using x and y coordinates ? i.e. angle i 45 degree then @ given x = 2 , y = 2
create a line of lets say 5 units @ (x,y) (2,2) ( i.e. x and y coordinates are used only to get a center point where the line has to be drawn )

@yogi_dhiman I do not understand what you are trying to change.

The above uses go.Scatter. Each trace consits of two points and uses the argument marker='markers+lines' thats why you see a line. The first point is not shown as the size for marker is set to 0 marker={'size': [0,10]

You can change the lenght of the lines to plot by changing the value of the corresponding variable lenght