Skip to content

[Bug]: Polar plot error bars don't rotate with angle for set_theta_direction and set_theta_offset #27784

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

Closed
th0ger opened this issue Feb 13, 2024 · 3 comments

Comments

@th0ger
Copy link

th0ger commented Feb 13, 2024

Bug summary

Reopening #441 since the fix seems not to work on two corner cases:

  • Clockwise direction with set_theta_direction(-1)
  • Angle offset set by set_theta_offset(np.pi/2)

Code for reproduction

from numpy import *
from matplotlib import pyplot as py

r = zeros([16])
err = zeros([16])
for i in range(16):
    r[i] = random.randint(400, 600)
    err[i] = random.randint(20, 50)
theta = arange(0, 2 * pi, 2 * pi / 16)
width = pi * 2 / 16

fig = py.figure(figsize=(8, 8))
ax = fig.add_axes([0.1, 0.1, 0.75, 0.79], polar=True)

bars = ax.bar(
    theta + pi / 16,
    r,
    width=width,
    bottom=0.0,
    yerr=err,
    capsize=15 # Capsize set to exaggerate issue
    )  
ax.set_ylim(0, 700)

ax.set_theta_direction(-1)  # Clockwise direction

py.show()
from numpy import *
from matplotlib import pyplot as py

r = zeros([16])
err = zeros([16])
for i in range(16):
    r[i] = random.randint(400, 600)
    err[i] = random.randint(20, 50)
theta = arange(0, 2 * pi, 2 * pi / 16)
width = pi * 2 / 16

fig = py.figure(figsize=(8, 8))
ax = fig.add_axes([0.1, 0.1, 0.75, 0.79], polar=True)

bars = ax.bar(
    theta + pi / 16,
    r,
    width=width,
    bottom=0.0,
    yerr=err,
    capsize=15 # Capsize set to exaggerate issue
    )  
ax.set_ylim(0, 700)

ax.set_theta_offset(np.pi/2)  # Start from the top

py.show()

Actual outcome

image
image

Expected outcome

Errorbar caps perpendicular to the error bars.

Additional information

No response

Operating system

Ubuntu

Matplotlib Version

3.8.1

Matplotlib Backend

agg

Python version

3.11.4

Jupyter version

7.0.6

Installation

None

@dstansby
Copy link
Member

I just had a go at this, and it's not a simple fix because the errorbar rotations are done before drawing, but the Axes offset/direction are only known/set at draw time.

@dstansby
Copy link
Member

Thanks for the clear report though!

@QuLogic
Copy link
Member

QuLogic commented Oct 31, 2024

This was fixed by #28966.

@QuLogic QuLogic closed this as completed Oct 31, 2024
@QuLogic QuLogic added this to the v3.10.0 milestone Oct 31, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants