-
-
Notifications
You must be signed in to change notification settings - Fork 1.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add legend 'auto' x|y and/or 'container' (x|y)ref #1199
Comments
This is happening because x: 0,
xanchor: 'left',
y: 1.1,
yanchor: 'bottom' @etpinard Would it make sense to make the defaults smarter and check the value of |
I don't think The problem in my eyes is that – when |
This comment has been minimized.
This comment has been minimized.
I was having a similar issue with the horizontal legend overlapping x axis values, when the x axis values were long enough, like dates. I'm adding this here because it's the only issue that comes up when you google it, and it seems related. This happens with only setting {legend: 'horizontal'} in the layout and nothing else. I tried a couple of different things, like playing with layout.legend.yanchor and the margins, but the legend doesn't appear to be affected by margins, it stays in the same place relative to the dates, and yanchor shifts it a little bit but it remains on top of the x axis ticks. In the end my solution was to absolutely position the legend using This has the side effect of putting the legend on top of the graph, but you can position it below the graph by lowering the Y value. It appears that the default X and Y values according to the docs (1, 1.2) are changed to a different value when the legend is set to horizontal, which makes sense, but should also be reflected in the documentation here: https://plot.ly/javascript/reference/#layout-legend I chose to put it above the graph because I know my x axis values are going to change in length and the graph is being iframed into a small spot, so I don't want to waste space. Not super pretty or anything, but a reasonable workaround. Hopefully the horizontal legends are changed so that it will take into account x axis tick length automatically, or there's another easy way to do it I haven't found. |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
7 similar comments
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
1 similar comment
This comment has been minimized.
This comment has been minimized.
Although I appreciate the great demand for a fix of this issue, I doubt that all the "+1" comments (and the thereby triggered e-mail notifications) will eventually help to motivate the plotly developers to finally implement a solution for the problem. So just use GitHub reactions to express your support, please 😉 |
This comment has been minimized.
This comment has been minimized.
Digging into this a little in relation to #2243 - the background:
I see two possible ways to go here. The first is less of an addition to what we currently have, but the second I think would be more powerful and probably easier to implement too:
|
This comment has been minimized.
This comment has been minimized.
Is the mechanism here because longer labels means pushing the margins up means in effect moving the (0,0) coordinate that the paper/domain coordinate space works within? |
I think I'm understanding the problem and suggested solutions better now... the |
Moved to |
Is there any update on this? I have some legends with a lot of text, the text is dynamic, so I can't do much about hose long the text is. When the chart generates, the legend overlaps the x-axis legend considerably. Is there anything the community can do to help? |
If someone wants to take on some implementation work, we'd be happy to iterate on a design and review some PRs, but at the moment this is no longer on our short-term roadmap. If you work for an organization with a software budget, you could sponsor this feature to bump it up our priority list. |
|
Great! :) |
This issue has been tagged with A community PR for this feature would certainly be welcome, but our experience is deeper features like this are difficult to complete without the Plotly maintainers leading the effort. Sponsorship range: $10k-$15k What Sponsorship includes:
Please include the link to this issue when contacting us to discuss. |
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. |
these layout settings allowed me to avoid this issue occurring entirely: |
@alexcjohnson @hannahker |
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). 🙂 |
With the settings, I still need to set a proper |
I still have this issue, what settings worked for you? thanks |
The code for the plot in the first post auto-scales perfectly with recent versions of plotly.js: Bildschirmaufzeichnung.vom.19.06.2024.23.03.30.webm |
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.
The text was updated successfully, but these errors were encountered: