Skip to content

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

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

Open
anntzer opened this issue Jul 27, 2019 · 4 comments · May be fixed by #14899
Open

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

anntzer opened this issue Jul 27, 2019 · 4 comments · May be fixed by #14899
Labels
keep Items to be ignored by the “Stale” Github Action

Comments

@anntzer
Copy link
Contributor

anntzer commented Jul 27, 2019

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:
@efiring
Copy link
Member

efiring commented Aug 5, 2019

The problem with this example goes beyond apply_aspect. Try running the example without the plt.axis('equal') call. With mpl 3.1.1 I get a blank box with default 0-1 xlim and ylim.

@anntzer
Copy link
Contributor Author

anntzer commented Aug 6, 2019

Oh, that's funny. Indeed, the 0-1 behavior is reproducible even with the default style.
Looks like what's missing is a call to self._request_autoscale_view() at the end of pie() (just like it is present at the end of nearly every other axes plotting method). Calling axis("equal") (which used to happen at the end of nearly every pie() call -- until we recently changed pie() to call ax.set_aspect("equal") itself) hid that problem because axis("equal") not only sets the aspect to "equal", but additionally performs an autoscale.

@github-actions
Copy link

This issue has been marked "inactive" because it has been 365 days since the last comment. If this issue is still present in recent Matplotlib releases, or the feature request is still wanted, please leave a comment and this label will be removed. If there are no updates in another 30 days, this issue will be automatically closed, but you are free to re-open or create a new issue if needed. We value issue reports, and this procedure is meant to help us resurface and prioritize issues that have not been addressed yet, not make them disappear. Thanks for your help!

@github-actions github-actions bot added the status: inactive Marked by the “Stale” Github Action label Jun 23, 2023
@anntzer
Copy link
Contributor Author

anntzer commented Jun 23, 2023

The exact repro I posted above is now fixed due to #19214, which is unrelated; the underlying issue is still present though:

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

x = [1.3732138971696957, 2.7835520805254377]
y = [1.055418483548192, 2.614880231147507]
plt.figure(figsize=(8, 8))
plt.plot(x, y, "o-", clip_on=False)
plt.axis('equal')

plt.show()

the bottom point is out of the autoscale range.
Figure_1

@anntzer anntzer added the keep Items to be ignored by the “Stale” Github Action label Jun 23, 2023
@rcomer rcomer removed the status: inactive Marked by the “Stale” Github Action label Jun 25, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
keep Items to be ignored by the “Stale” Github Action
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants