FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

[Bug]: Removing spines in polar plot causes distortion of the plot · Issue #30164 · matplotlib/matplotlib · GitHub

Repository navigation

[Bug]: Removing spines in polar plot causes distortion of the plot #30164

Closed

Description

Bug summary

I would like to create a polar plot without the grid lines. When using ax.set_xticks([]) (and/or yticks/rticks) the plot appears distorted.

Code for reproduction

import numpy as np
import matplotlib.pyplot as plt

D = np.array([[2,.3],[.3,2.5]])

# creating an ellipse)
lam, vec = np.linalg.eigh(D)
theta    = np.linspace(-np.pi,np.pi,1001)
xy       = np.stack((lam[0]*np.cos(theta), lam[1]*np.sin(theta)), axis=0)
xy       = vec.T@xy
radii    = np.sqrt(np.sum(xy**2, axis=0))
thetas   = np.arctan2(-xy[1],xy[0])

plt.figure()
# with ticks
ax1 = plt.subplot(121,projection='polar')
ax1.plot(thetas, radii)
# without ticks
ax2 = plt.subplot(122, projection='polar')
ax2.plot(thetas, radii)
ax2.set_yticks([])
ax2.set_xticks([])

plt.show()

Actual outcome

Expected outcome

Additional information

No response

Operating system

OS/X and Linux

Matplotlib Version

3.10.0

Matplotlib Backend

module://matplotlib_inline.backend_inline

Python version

3.10

Jupyter version

No response

Installation

None

Activity

  1. anntzer commented on Jun 12, 2025

    Contributor

    This is essentially the same issue as the one fixed by #29798, but uses set_yticks instead of set_rticks. I suspect that PolarAxes.set_yticks should get the same treatment (of wrapping into a RadialLocator); indeed, using set_rticks([]) works fine as of HEAD.

  2. timhoffm commented on Jun 13, 2025

    Member

    Fundamentally, shouldn't we implment everything in set_yticks and make set_rticks only a synonym of that?

  3. anntzer commented on Jun 13, 2025

    Contributor

    Yes, I would think so.

  4. timhoffm commented on Jun 13, 2025

    Member

    Actually, I think the proper solution must go deeper. In the end, this is a topic that should be handled within RadialAxis. The locator should always be wrapped in a RadialLocator, so I would say that set_major_locator should be overridden to ensure the wrapping.

    There's already a helper function for wrapping:

    def _wrap_locator_formatter(self):
    self.set_major_locator(RadialLocator(self.get_major_locator(),
    self.axes))
    self.isDefault_majloc = True

    but I'm unclear what the isDefault_majloc is doing and whether we need it. Also, this helper is called explicitly - do we still need that if RadialAxis.set_major_locator will do the wrapping? @QuLogic you seem to have introduced this in #9068 do you still remember?

  5. added 2 commits that reference this issue on Jun 13, 2025
    5c6d199
    a4806aa
  6. added 4 commits that reference this issue on Jun 20, 2025
  7. added a commit that references this issue on Jul 11, 2025
    b02ed41
  8. added this to the v3.11.0 milestone on Jul 14, 2025
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


      Back | FazBrowse Home | New Git URL