Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Polar plot error bars don't rotate with angle #441

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
drwebb opened this issue Aug 29, 2011 · 20 comments · Fixed by #23592
Closed

Polar plot error bars don't rotate with angle #441

drwebb opened this issue Aug 29, 2011 · 20 comments · Fixed by #23592

Comments

@drwebb
Copy link

drwebb commented Aug 29, 2011

In this example the errorbars do not align with the theta of bar. I posted this as a question at stackoverflow, and maybe the answer could be useful. Surely, this should not be default behavior though.

Example non-working code:

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)
ax.set_ylim(0,700)
py.show()
@efiring
Copy link
Member

efiring commented Jul 21, 2013

As of mpl 1.2.1 the error bar itself does align with theta, but the error bar cap does not. The cap is implemented as a marker, so either we need a way to specify the rotation of markers, or the cap needs to be implemented as a LineCollection, or perhaps as a gappy line.

@tacaswell
Copy link
Member

This is still the state on master

@crypdick
Copy link

crypdick commented Jul 9, 2015

It seems to me like this has been resolved? Attached is the plot that the figure produces.

figure_1

@QuLogic
Copy link
Member

QuLogic commented Jul 15, 2015

@isomerase I think it's only correct for you because you are using a style that hides the caps. The caps are still not rotated on master.

@tacaswell tacaswell modified the milestones: 2.1 (next point release), 2.2 (next next feature release) Sep 24, 2017
@tacaswell
Copy link
Member

Still a bug 😞 but less visible now that the default style has no caps.

@thmosqueiro
Copy link

thmosqueiro commented Mar 4, 2018

Just trying to understand the state of this issue: is this still open and scheduled for a future release? Could I submit a PR with a fix?
After playing for a bit with a fork of this repository using a fix I've been using for a year now, I'm pretty sure I can patch it and submit a PR. I just wanted to ask before spending too much time on it.

@dstansby
Copy link
Member

dstansby commented Mar 5, 2018

I'm pretty sure this is still open, so if you have a fix a PR would be very appreciated!

@thmosqueiro
Copy link

Thanks for the reply, @dstansby. I just did some tests including my patch on the source code (version 2.1.2), and it seems to fix this problem in my plots, and the OP's plot without changing their script. An example using polar coordinates would be good too, what do you think?

Also, I may have some minor questions, is gitter an appropriate channel for that?

@jklymak
Copy link
Member

jklymak commented Mar 5, 2018

yes, gitter is great for dev chat, including minor dev questions.

@efiring
Copy link
Member

efiring commented Jun 11, 2018

Progress, @thmosqueiro? It is OK to submit a PR that is "Work in Progress", if that can help move it along.

@thmosqueiro
Copy link

thmosqueiro commented Jun 11, 2018

Hi @efiring. Apologies for the delay, I had to relocate recently.

I actually have a local version that works and fixes the issues I had, and the issue originally reported. I like this idea of a "Work in Progress" kind of PR. I will post more info within a couple of days.

@RoryIAngus
Copy link
Contributor

Hi @thmosqueiro, I was wondering if you had managed to find some time to do this?
I have just come across this issue and it would be helpful to get it resolved.

If you haven't got the time to invest, could you share your code and I can go through the process of getting updated?

Many thanks

@efiring
Copy link
Member

efiring commented May 23, 2019

@thmosqueiro If you and @RoryIAngus could come up with a PR that solves this problem cleanly, that would be much appreciated. I would love to be able to close this issue, which dates back to 2011.

@thmosqueiro
Copy link

@efiring my current employment is prohibitive regarding open source contributions. I however would not mind sharing what I have done until before I got hired, which is documented and could be finalized by someone else. I talked to @jaquejbrito and she's interested in taking over my code and take responsibility over this task. I can most definitely provide her with feedback IRL and in here. Also, I'm sure if @RoryIAngus wants to also contribute, she'd be glad to have someone else to work with.

So @efiring she says that she could get started as soon as tomorrow. Sounds good?

@efiring
Copy link
Member

efiring commented May 23, 2019

Thank you.

@RoryIAngus
Copy link
Contributor

RoryIAngus commented May 23, 2019 via email

@jaquejbrito
Copy link

Hi.
I'll start checking the code. After we can start working on it.
Tks

@RoryIAngus
Copy link
Contributor

Some code to recreate the error showing the end cap issue and how it is not rotating but staying aligned to the horizontal plane.

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)
py.show()

image

@jaquejbrito
Copy link

Thanks for the sample code. I’m taking a look at thiago’s code, and should be able to stage his current changes in a forked repository soon.

@GentilsTo
Copy link

Hey, @jaquejbrito, any progress related?

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

Successfully merging a pull request may close this issue.