You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I couldn't find any way to configure legend to be placed under the chart in a single line. It would be nice if Plotly makes it possible to move the legend below the chart.
For anybody wanting to place the legend under the chart, one way to achieve this would be like so:
layout: {
....
legend:{
xanchor:"center",
yanchor:"top",
y:-0.3, // play with it
x:0.5 // play with it
}
}
You can also check out the effects of the x/yanchor and x/y values on https://plot.ly/plot: plot a graph, then change Layout -> Horz Position, Vert Position, Horz anchor, Vert anchor.
Reacted by Angel Beltre, Matt Fehskens, Mustafa Furkan Süve, pdfabbro, terenceng2010, Vishal Sharma, Courtney Christensen, qang1, Zach Wolfe, Lorhan Sohaky and 5 more
Reacted by Michael E. Rose, Miguel Angel Perez, pdfabbro and Lorhan Sohaky
I came here after receiving the following message:
Warning message:
plotly.js does not (yet) support horizontal legend items
You can track progress here:
https://github.com/plotly/plotly.js/issues/53
I do not usually receive this warning message. In a ggplot2 object processed by plotly I set guides(colour = guide_legend(ncol=1)), clearly requesting a vertical legend (not a single-line horizontal legend), which works as expected. I came to this issue as directed by the warning message and see this issue is now closed: Is this warning still relevant? Thanks.
When I set the legend to 'h', but it only moves the legend title to the side, the variable legends are still vertically aligned. I couldn't get one below the other.
Activity
etpinard commentedon Dec 1, 2015
@prog8 correct. plotly.js legends don't offer much in terms of customization.
You can move the legend using
layout.legend.xandlayout.legend.y, but there's no way to place the items horizontally at the moment.prog8 commentedon Dec 1, 2015
Is it planned to make legends more customizable in nearest future? If yes do you know any estimates?
czellweg commentedon Dec 2, 2015
For anybody wanting to place the legend under the chart, one way to achieve this would be like so:
You can also check out the effects of the x/yanchor and x/y values on https://plot.ly/plot: plot a graph, then change Layout -> Horz Position, Vert Position, Horz anchor, Vert anchor.
prog8 commentedon Dec 2, 2015
Yes but this doesn't change the legend layout. Legend entries are always one below another. They are never in the same line.
n-riesco commentedon Apr 26, 2016
@etpinard @mdtusz I'm thinking of the following API for this feature:
etpinard commentedon Apr 26, 2016
@n-riesco I'd vote for
similar to bar
orientation.mdtusz commentedon Apr 26, 2016
⬆️ agreed, but only for the sake of consistency with the existing style.
Merge pull request #535 from n-riesco/legend-orientation
ptoche commentedon Sep 15, 2018
I came here after receiving the following message:
I do not usually receive this warning message. In a
ggplot2object processed byplotlyI setguides(colour = guide_legend(ncol=1)), clearly requesting a vertical legend (not a single-line horizontal legend), which works as expected. I came to this issue as directed by the warning message and see this issue is now closed: Is this warning still relevant? Thanks.alexcjohnson commentedon Sep 15, 2018
@cpsievert ^^ ?
mikkokotila commentedon Jan 12, 2019
Is there any update on this?
EDITED: Amazing. It's working as per the above format.
marwin1991 commentedon Jan 12, 2019
legend is coverd by x-axies label
mikkokotila commentedon Jan 12, 2019
@marwin1991 Try something like this >
{legend: {x: 0.35, y: 5, orientation: 'h'},marwin1991 commentedon Jan 12, 2019
this helps
usser123 commentedon Apr 23, 2020
Horizontal legend is not working for me. Is this a bug ?
MikkoHaavisto commentedon Apr 3, 2021
When I set the legend to 'h', but it only moves the legend title to the side, the variable legends are still vertically aligned. I couldn't get one below the other.
Is this feature working for someone?
nicolaskruchten commentedon Apr 4, 2021
Yes, this works for me: https://codepen.io/nicolaskruchten/pen/JjENwZZ?editors=0010 ... it looks like this:
Quiet warning