Skip to content

Make pie charts circular by default #10789

Closed

Description

@nicoguaro

Bug report

Bug summary

The default configuration for pie charts should give circular pies. That is in the definition according to Wikipedia:

A pie chart (or a circle chart) is a circular statistical graphic which is divided into slices to illustrate numerical proportion.

See for example: https://kosara.net/papers/2016/Kosara-EuroVis-2016.pdf

Code for reproduction

import matplotlib.pyplot as plt

plt.pie([10, 90])
plt.show()

pie_ellipse

Actual outcome

Expected outcome

The expected outcome is the following

pie_circle

This is obtained by the following snippet

import matplotlib.pyplot as plt

plt.pie([10, 90])
plt.axis("image")
plt.show()

Matplotlib version

  • Operating system: Linux Mint
  • Matplotlib version: 2.1.2
  • Matplotlib backend (print(matplotlib.get_backend())): Qt5Agg
  • Python version: 3.6.4
  • Distribution: Anaconda custom (64-bit)| (default, Jan 16 2018, 18:10:19)

Activity

  1. Imanflow commented on Mar 26, 2018

    @Imanflow

    I saw this tagged as a good first issue and I started looking at it. Not only using plt.axis("image") works, also with equal and scaled.

    I checked the code in pyplot.py and _axes.py and I fail to see clearly what should be modified in order to make it by default, but with a bit of guidance I would take the issue.

  2. ImportanceOfBeingErnest commented on Mar 26, 2018

    @ImportanceOfBeingErnest
    Member

    I should think this is as easy as adding

    self.set_aspect("equal")
    

    in the pie method of Axes in _axes.py (around line 2792 of the current master).

    But it should probably get a "what's new"-entry.

  3. Imanflow commented on Mar 26, 2018

    @Imanflow

    the what's new entry could be something like:

    Circular pie charts by default

    Added equal aspect to the axes in plt.pie by default to ensure a circular image.

    What do you think?

  4. added this to the milestone on Mar 27, 2018
  5. tacaswell commented on Mar 27, 2018

    @tacaswell
    Member

    This seems like a very odd oversite, is this a regression from earlier versions of Matplotlib?

  6. ImportanceOfBeingErnest commented on Mar 27, 2018

    @ImportanceOfBeingErnest
    Member

    @tacaswell I don't think so, the examples in versions 1.3, 1.4, 1.5, 2.0 all have some line with plt.axis("equal") or ax1.axis('equal') in them. (Which is of course not a sufficient criterium 🙈)

    As a what's new entry I could imagine the following:

    We acknowledge that the majority of people do not like egg-shaped pies. Therefore, an axes to which a pie chart is plotted will be set to have equal aspect ratio by default. This ensures that the pie appears circular independent on the axes size or units. To revert to the previous behaviour you may set the axes' aspect to automatic, ax.set_aspect("auto") or plt.axis("auto").

  7. Imanflow commented on Mar 27, 2018

    @Imanflow

    apparently @jerrylui803 was working on it without commenting here... he opened a pullrequest yesterday.

    #10887

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions