Skip to content

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

Closed

Description

@drwebb

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()

Activity

  1. efiring commented on Jul 21, 2013

    @efiring
    Member

    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.

  2. tacaswell commented on Jan 17, 2014

    @tacaswell
    Member

    This is still the state on master

  3. crypdick commented on Jul 9, 2015

    @crypdick

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

    figure_1

  4. QuLogic commented on Jul 15, 2015

    @QuLogic
    Member

    @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.

  5. modified the milestones: , on Sep 24, 2017
  6. tacaswell commented on Sep 24, 2017

    @tacaswell
    Member

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

  7. thmosqueiro commented on Mar 4, 2018

    @thmosqueiro

    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.

  8. dstansby commented on Mar 5, 2018

    @dstansby
    Member

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

  9. thmosqueiro commented on Mar 5, 2018

    @thmosqueiro

    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?

  10. jklymak commented on Mar 5, 2018

    @jklymak
    Member

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

  11. efiring commented on Jun 11, 2018

    @efiring
    Member

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

  12. thmosqueiro commented on Jun 11, 2018

    @thmosqueiro

    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.

  13. RoryIAngus commented on Dec 17, 2018

    @RoryIAngus
    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

  14. efiring commented on May 23, 2019

    @efiring
    Member

    @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.

  15. thmosqueiro commented on May 23, 2019

    @thmosqueiro

    @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?

  16. efiring commented on May 23, 2019

    @efiring
    Member

    Thank you.

  17. RoryIAngus commented on May 23, 2019

    @RoryIAngus
    Contributor
  18. jaquejbrito commented on May 23, 2019

    @jaquejbrito

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

  19. RoryIAngus commented on May 24, 2019

    @RoryIAngus
    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

  20. jaquejbrito commented on May 24, 2019

    @jaquejbrito

    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.

  21. GentilsTo commented on Nov 21, 2020

    @GentilsTo

    Hey, @jaquejbrito, any progress related?

  22. linked a pull request that will close this issuePolar errcaps #23592on Aug 12, 2022
  23. modified the milestones: future releases, v3.7.0 on Oct 7, 2022
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