I am using the plotly.graph_objects.Figure.add_annotation()
function to add an arrow into an interactive plot - for example:
import plotly.graph_objects as go
import plotly.io as pio
pio.renderers.default = 'browser'
fig = go.Figure()
fig.add_annotation(ax = 1, axref = 'x', ay = 1, ayref = 'y',
x = 2, xref = 'x', y = 1, yref = 'y',
arrowwidth = 5, arrowhead = 3)
fig.update_layout(xaxis_range = [0, 3], yaxis_range = [0, 2])
fig.show()
This renders the arrow just fine:
However, when I use the pan tool (β₯) to move the axes around, the arrow is entirely visible as long as either its head or its tail is on the axes - as seen here with the arrow head extending beyond the boundaries of the axes:
The same happens with the arrow tail. As a sidenote, similar outcome can be also achieved directly (without having to use the pan tool) by setting the layout as follows before calling fig.show()
:
fig.update_layout(xaxis_range = [-1.2, 1.8], yaxis_range = [0, 2])
Instead, this is what my desired outcome would be:
I havenβt found any clues in the documentation.
Is there a way to restrict visibility of the arrow only to the extent of the visible axes?