Repository navigation
Horizontal Legend below the chart #53
Description
Activity
@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.Is it planned to make legends more customizable in nearest future? If yes do you know any estimates?
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 moreReacted by Michael E. Rose, Miguel Angel Perez, pdfabbro and Lorhan SohakyYes but this doesn't change the legend layout. Legend entries are always one below another. They are never in the same line.
- Reacted by Nicolas Riesco, Alex Parij, Miguel Alberto Plazas, Zach Wolfe, Jonathan Fraine and Dmitry513
⬆️ agreed, but only for the sake of consistency with the existing style.
- added a commit that references this issue
on May 17, 2016 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/53I 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.@cpsievert ^^ ?
Is there any update on this?
EDITED: Amazing. It's working as per the above format.
@marwin1991 Try something like this >
{legend: {x: 0.35, y: 5, orientation: 'h'},legend : { orientation: 'h', y:-0.15 },this helps
Reacted by Deyan Spasov, Kyubin Han and Miguel Alberto PlazasHorizontal legend is not working for me. Is this a bug ?
Reacted by MikkoHaavistoWhen 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?
Yes, this works for me: https://codepen.io/nicolaskruchten/pen/JjENwZZ?editors=0010 ... it looks like this:


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.