Skip to content

New 'outside' locations for legend #3857

Closed

Description

@mrkrd

So far placement of legend using the loc argument is limited to the inside of the axis (e.g. right, center, upper left, etc). However, often the plotting area is cluttered with the data points, and it is desired to place the legend outside of the axis, as for example described in http://matplotlib.org/users/legend_guide.html#legend-location

It would be useful to have additional loc values for quick and intuitive placement of the legend outside of the axis:

plt.legend(loc='outside right center')

Activity

  1. added this to the milestone on Nov 27, 2014
  2. WeatherGod commented on Nov 28, 2014

    @WeatherGod
    Member

    I like this idea in principle, and it shouldn't be too difficult to
    implement. The tricky part will be in making room outside the plot area.
    Should the subplot area be shrunk or should the figure size be expanded? In
    keeping with the current design of matplotlib, I would vote for shrinking
    the subplot region, but that may not be desirable (especially with figures
    that have aspect ratios set).

    Ultimately, though, this idea is leaps and bounds better than the current
    solution of trying to remember how to manually force it.

    On Thu, Nov 27, 2014 at 7:54 AM, mrkrd notifications@github.com wrote:

    So far placement of legend using the loc argument is limited to the
    inside of the axis (e.g. right, center, upper left, etc). However, often
    the plotting area is cluttered with the data points, and it is desired to
    place the legend outside of the axis, as for example described in
    http://matplotlib.org/users/legend_guide.html#legend-location

    It would be useful to have additional loc values for quick and intuitive
    placement of the legend outside of the axis:

    plt.legend(loc='outside right center')

    —
    Reply to this email directly or view it on GitHub
    #3857.

  3. tacaswell commented on Nov 28, 2014

    @tacaswell
    Member

    This still comes back to needing to get the constraint-engine working.

  4. petehuang commented on Dec 30, 2016

    @petehuang
    Contributor

    #6182 made some good progress but has stalled since then. PR welcome - it would address #3745 as well.

    Recommend labeling with Difficulty: Easy?

  5. isentropic commented on Jun 13, 2022

    @isentropic

    I'd like this feature too, but there might be some aspect ratio problems / figure size problems, as now it complicated the layouting

  6. jklymak commented on Jun 13, 2022

    @jklymak
    Member

    See #19743. That got bogged down in the whole anchor dance, which is super flexible but actually a pain to deal with conceptually and algorithmically.

  7. modified the milestones: , needs sorting on Oct 6, 2022
  8. QuLogic commented on May 4, 2023

    @QuLogic
    Member

    I guess this is fixed by #19743.

  9. modified the milestones: future releases, v3.7.0 on May 4, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions