Skip to content

"round_numbers" axis limits + axis("equal") sometimes sends artists out of axes limits. #14898

Open
@anntzer

Description

@anntzer

Bug report

Bug summary

The following is slightly modified from test_axes.py::test_pie_frame_grid, with only the center of the topmost pie slightly modified:

from pylab import *
from matplotlib import style; style.use("classic")

# The slices will be ordered and plotted counter-clockwise.
labels = 'Frogs', 'Hogs', 'Dogs', 'Logs'
sizes = [15, 30, 45, 10]
colors = ['yellowgreen', 'gold', 'lightskyblue', 'lightcoral']
# only "explode" the 2nd slice (i.e. 'Hogs')
explode = (0, 0.1, 0, 0)

plt.pie(sizes, explode=explode, labels=labels, colors=colors,
        autopct='%1.1f%%', shadow=True, startangle=90,
        wedgeprops={'linewidth': 0},
        frame=True, center=(2, 2))

plt.pie(sizes[::-1], explode=explode, labels=labels, colors=colors,
        autopct='%1.1f%%', shadow=True, startangle=90,
        wedgeprops={'linewidth': 0},
        frame=True, center=(5, 2))

plt.pie(sizes, explode=explode[::-1], labels=labels, colors=colors,
        autopct='%1.1f%%', shadow=True, startangle=90,
        wedgeprops={'linewidth': 0},
        # The original test has center=(3, 5)
        frame=True, center=(3, 4.9))
# Set aspect ratio to be equal so that pie is drawn as a circle.
plt.axis('equal')

plt.show()

This yields
test
which is clearly less than great...

Matplotlib version

  • Operating system: linux
  • Matplotlib version: master, but present at least since 2.0
  • Matplotlib backend (print(matplotlib.get_backend())): any
  • Python version: 37
  • Jupyter version (if applicable):
  • Other libraries:

Metadata

Metadata

Assignees

No one assigned

    Labels

    keepItems to be ignored by the “Stale” Github Action

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions