-
-
Notifications
You must be signed in to change notification settings - Fork 2.7k
Open
Labels
Description
It is written that now the recommended way of adding text annotations to shapes is by adding labels. But for that the textposition
is only working for ["start", "middle", "end"]
.
Here an MWE:
import plotly.express as px
fig = px.scatter(y=[0, 11])
# REF: <https://plotly.com/python/reference/layout/shapes/#layout-shapes-items-shape-label-textposition>
positions = [
"top left", "top center", "top right",
"middle left", "middle center", "middle right",
"bottom left", "bottom center", "bottom right",
"start", "middle", "end",
]
for i, position in enumerate(positions):
fig.add_hline(
y=i,
label=dict(
text=position,
textposition=position,
font_color="red",
),
line_color="red",
)
# # same for vertical lines
# fig.add_vline(
# x=i,
# label=dict(
# text=position,
# textposition=position,
# font_color="green",
# ),
# line_color="green",
# )
)
which gives