title: Plotly: Annotate using secondary y-axis
body: <p>I have taken an <a href="https://plotly.com/python/text-and-annotations/" rel="nofollow noreferrer">expamle from plotly</a>. And modified it so that the second trace plots on a secondary_y axis. I want to annotate a point on that <strong>line using the secondary axis as reference.</strong></p>
  <p>Here is the code:</p>
  <pre class="lang-py prettyprint-override"><code>import plotly.graph_objects as go
  
  fig = make_subplots(specs=[[{&quot;secondary_y&quot;: True}]])
  
  fig.add_trace(go.Scatter(
     x=[0, 1, 2, 3, 4, 5, 6, 7, 8],
     y=[0, 11, 31, 21, 41, 31, 41, 61, 51]
  ))
  
  fig.add_trace(go.Scatter(
     x=[0, 1, 2, 3, 4, 5, 6, 7, 8],
     y=[0, 4, 5, 1, 2, 2, 3, 4, 2]
  ), secondary_y=True)
  
  fig.add_annotation(
         x=2,
         y=5,
         xref=&quot;x&quot;,
         yref=&quot;y&quot;,
         text=&quot;max=5&quot;,
         showarrow=True,
         font=dict(
             family=&quot;Courier New, monospace&quot;,
             size=16,
             color=&quot;#ffffff&quot;
             ),
         align=&quot;center&quot;,
         arrowhead=2,
         arrowsize=1,
         arrowwidth=2,
         arrowcolor=&quot;#636363&quot;,
         ax=20,
         ay=-30,
         bordercolor=&quot;#c7c7c7&quot;,
         borderwidth=2,
         borderpad=4,
         bgcolor=&quot;#ff7f0e&quot;,
         opacity=0.8
         )
  
  fig.update_layout()
  </code></pre>
  <p>This is what comes out, the annotation should be on the second line.
  <a href="https://i.stack.imgur.com/cN1YO.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/cN1YO.png" alt="Output, Annotation not on line" /></a></p>