Plotly Annotations are always showing on top of plot trace

57 views Asked by At

var trace2 = {
  x: [0, 1, 2, 3, 4, 5, 6, 7, 8],
  y: [0, 4, 5, 1, 2, 2, 3, 4, 2],
  type: 'scatter'
};
var layout = {
  showlegend: false,
  annotations: [
    {
      x: 2,
      y: 5,
      xref: 'x',
      yref: 'y',
      text: 'max=5',
      showarrow: false,
      bgcolor: '#ff7f0e',
      opacity: 1
    }
  ]
};
Plotly.newPlot('myDiv',  [trace2], layout);
<head>
    <!-- Load plotly.js into the DOM -->
    <script src='https://cdn.plot.ly/plotly-2.27.0.min.js'></script>
</head>

<body>
    <div id='myDiv'><!-- Plotly chart will be drawn inside this DIV --></div>
</body>

I am facing an issue in showing annotations with border and fill color below the plot trace. Every time plot data is showing below annotation.

Example screenshot

My requirement is plot trace should be on top of annotations.

any solutions or tips to handle are most welcome.

0

There are 0 answers