Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

plotly.js legend overlap the graph

Tags:

plotly.js

Please see example screenshot - I cannot reproduce except on this site, it seems to be some conflict with the css but any ideas what?

Normally, plotly moves the legend at the top if there is not enough horizontal space. However, this example shows that the legend overlaps the graph. Even if I make the legend orientation horizontal, it still overlaps the graph.

Do you have any ideas why it could happen?

enter image description here

like image 437
kroky Avatar asked Mar 21 '26 13:03

kroky


2 Answers

Adjusting the legend position in normalized coordinates should help. See also here. I.e.:

layout = go.Layout(
     legend={"x" : 1.2, "y" : 1}
)
like image 99
Crashdomi Avatar answered Mar 24 '26 23:03

Crashdomi


Placing the legend outside of the plot works for me:

var layout = {
  showlegend: true,
  legend: {
    x: 1,
  }
};
like image 39
Marciolegal Avatar answered Mar 25 '26 00:03

Marciolegal