Skip to content
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

Horizontal Legend below the chart #53

Closed
prog8 opened this issue Dec 1, 2015 · 16 comments · Fixed by #535
Closed

Horizontal Legend below the chart #53

prog8 opened this issue Dec 1, 2015 · 16 comments · Fixed by #535
Assignees
Labels
feature something new

Comments

@prog8
Copy link

prog8 commented Dec 1, 2015

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.

@etpinard
Copy link
Contributor

etpinard commented Dec 1, 2015

@prog8 correct. plotly.js legends don't offer much in terms of customization.

You can move the legend using layout.legend.x and layout.legend.y, but there's no way to place the items horizontally at the moment.

@prog8
Copy link
Author

prog8 commented Dec 1, 2015

Is it planned to make legends more customizable in nearest future? If yes do you know any estimates?

@czellweg
Copy link

czellweg commented Dec 2, 2015

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.

@prog8
Copy link
Author

prog8 commented 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
Copy link
Contributor

n-riesco commented Apr 26, 2016

@etpinard @mdtusz I'm thinking of the following API for this feature:

layout: {
    legend : {
        orientation: 'horizontal' | 'vertical'
    }
}

@etpinard
Copy link
Contributor

etpinard commented Apr 26, 2016

@n-riesco I'd vote for

layout: {
    legend : {
        orientation: 'h' | 'v'
    }
}

similar to bar orientation.

@mdtusz
Copy link
Contributor

mdtusz commented Apr 26, 2016

⬆️ agreed, but only for the sake of consistency with the existing style.

@ptoche
Copy link

ptoche commented Sep 15, 2018

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.

@alexcjohnson
Copy link
Collaborator

@cpsievert ^^ ?

@mikkokotila
Copy link

mikkokotila commented Jan 12, 2019

Is there any update on this?

EDITED: Amazing. It's working as per the above format.

@marwin1991
Copy link

image

legend is coverd by x-axies label

@mikkokotila
Copy link

@marwin1991 Try something like this > {legend: {x: 0.35, y: 5, orientation: 'h'},

@marwin1991
Copy link

                    legend : {
                        orientation: 'h',
                        y:-0.15
                    },

this helps

@usser123
Copy link

Horizontal legend is not working for me. Is this a bug ?

@MikkoHaavisto
Copy link

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
Copy link
Contributor

Yes, this works for me: https://codepen.io/nicolaskruchten/pen/JjENwZZ?editors=0010 ... it looks like this:

newplot

pjastam added a commit to pjastam/fifa-ranking that referenced this issue Jun 14, 2024
Warning: plotly.js does not (yet) support horizontal legend items
You can track progress here:
plotly/plotly.js#53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature something new
Projects
None yet
Development

Successfully merging a pull request may close this issue.