I'm trying to add annotations arrows to a plotly polar plot, but that produces another underlying cartesian plot:
Question 1: is there a way to add annotation to polar plots? This page of 2019 suggest that not, is it still the current status?: https://community.plotly.com/t/adding-annotations-to-polar-scatterplots/704
Question 2: is there a hack to produce arrows on a polar plot? (hide aligned overlying transparent cartesian plot? low level draw of arrows with lines in polar plot?)
The code producing the above image is here:
import plotly.express as px
import plotly.graph_objects as go
import pandas as pd
df = pd.DataFrame()
fig = px.scatter_polar(
df,
theta=None,
r=None,
range_theta=[-180, 180],
start_angle=0,
direction="counterclockwise",
template="plotly_white",
)
x_end = [1, 2, 2]
y_end = [3, 5, 4]
x_start = [0, 1, 3]
y_start = [4, 4, 4]
list_of_all_arrows = []
for x0, y0, x1, y1 in zip(x_end, y_end, x_start, y_start):
arrow = go.layout.Annotation(dict(
x=x0,
y=y0,
xref="x", yref="y",
text="",
showarrow=True,
axref="x", ayref='y',
ax=x1,
ay=y1,
arrowhead=3,
arrowwidth=1.5,
arrowcolor='rgb(255,51,0)', )
)
list_of_all_arrows.append(arrow)
fig.update_layout(annotations=list_of_all_arrows)
fig.show()
Edit:
In fine, I would like to have something like that, with annotation relative to polar plot:
Here is what I coded.
This yields,
I hope I have answered your question.