Add legend 'auto' x|y and/or 'container' (x|y)ref
The problem is that the horizontal legend overlaps the x-axis title. It occurs if the legend is positioned below (rather than to the right of) the plot area using layout = {legend: {"orientation": "h"}};. It aggravates in combination with multiline x-axis titles (using <br> tags).
Currently there's no way to control the spacing between the legend and the plotting area. Everything is auto-scaled, it is useless to set the bottom margin (layout = {margin: {"b": ...}};) in this case because it refers to the space below the legend. The only way to make the whole x-axis title visible is to increase the height of the whole plot until the autoscaling sufficiently spreads the legend and the plotting area apart.
I try to illustrate the problem with the following 3 images which differ only in frame height:
height 700px:

height 1000px:

height 1300px:

Here is the above plot hosted on plot.ly.
Setting layout.legend.y = "auto" and layout.legend.yanchor = "top" helped me to avoid legend overlapping on x-axis title
Resizing responsive plots multiple times in quick succession can also cause the legend to overlap with the rest of the plot. After the bug occurs, triggering a resize by in- or decreasing by a few px and then returning to the previous page dimensions renders the plot correctly this time.
https://codepen.io/poomse8/pen/KKxVMjx
these layout settings allowed me to avoid this issue occurring entirely: 'yref': container 'yanchor': bottom 'xanchor': center 'x': 0.5 'orientation': 'h'
these layout settings allowed me to avoid this issue occurring entirely: 'yref': container 'yanchor': bottom 'xanchor': center 'x': 0.5 'orientation': 'h'
@alexcjohnson @hannahker Does that mean we could close this issue?
Does that mean we could close this issue?
Obviously I can't speak for the people you mentioned, but my original issue has indeed been fixed since I've last checked (2017). Tested with plotly.js v2.11.1 (included in the plotly R package 4.10.2). 🙂
these layout settings allowed me to avoid this issue occurring entirely: 'yref': container 'yanchor': bottom 'xanchor': center 'x': 0.5 'orientation': 'h'
@alexcjohnson @hannahker Does that mean we could close this issue?
With the settings, I still need to set a proper layout.margin.b manually to avoid overlapping between the X-axis title and the legend.
So I don't think the issue fixed completely...
Does that mean we could close this issue?
Obviously I can't speak for the people you mentioned, but my original issue has indeed been fixed since I've last checked (2017). Tested with plotly.js v2.11.1 (included in the plotly R package 4.10.2). 🙂
I still have this issue, what settings worked for you? thanks
I still have this issue, what settings worked for you?
The code for the plot in the first post auto-scales perfectly with recent versions of plotly.js: