Skip to content

mpl 2.1 barcharts edgecolor and linewidth only apply to first bar #9351

Closed

Description

@jolespin

I ran some code and realized it is only working on the first bar. I'm using Python 3.6.2, matplotlib 2.1. Just reverted back to 2.0.2.
image

Activity

  1. jolespin commented on Oct 10, 2017

    @jolespin
    Author

    image

  2. afvincent commented on Oct 10, 2017

    @afvincent
    Contributor

    I can confirm the issue with a fresh install of Matplotlib 2.1 (from conda) on GNU/Linux (Fedora 26), with Python 3.6.3 (from conda):

    import matplotlib.pyplot as plt
    import numpy as np
    
    fig, ax = plt.subplots(num='mwe_scalar_bar_ec')
    x = np.arange(1, 10)
    ax.bar(x, x, edgecolor="black", lw=3)
    
    fig.savefig(fig.get_label() + ".png")

    mwe_scalar_bar_ec

    Edit: the issue is on the master branch too (confirmed on 2.1.0.post222+gad730d131)

  3. added this to the milestone on Oct 10, 2017
  4. jolespin commented on Oct 10, 2017

    @jolespin
    Author

    Off topic but what does num='mwe_scalar_bar_ec' do?

  5. anntzer commented on Oct 10, 2017

    @anntzer
    Contributor

    See #9353.

  6. afvincent commented on Oct 10, 2017

    @afvincent
    Contributor

    @jolespin It defines the name of the figure. I then use it to define the name of the figure with fig.get_label() (personal habit). The name of the kwarg ('num') is due to the MATLAB legacy IIRC.

  7. afvincent commented on Oct 10, 2017

    @afvincent
    Contributor

    @anntzer You are too fast ^^... And git bisect indeed yells
    5348ce9551e2975050a495af1259294f03d3af12 is the first bad commit

  8. timhoffm commented on Nov 21, 2017

    @timhoffm
    Member

    Workaound

    The bug is just a missing broadcasting of the edgecolor. You can circumvent this by explicitly setting it for all bars:

    ax.bar(x, y, linewidth=3, edgecolor=['black']*len(x))
    
  9. wardakhan149 commented on Sep 4, 2018

    @wardakhan149

    i am using the code below.

    def show_hsv_hist(image):
        plt.figure(figsize=(20, 3))
        histr = cv2.calcHist([image], [0], None, [180], [0, 180])
        plt.xlim([0, 180])
        colours = [colors.hsv_to_rgb((i/180, 1, 0.9)) for i in range(0, 180)]
        plt.bar(range(0, 180), histr, color=colours, edgecolor = colours, width = 1)
        plt.title('Hue')
    
    

    and getting the following error:

    only size-1 arrays can be converted to Python scalars

    can someone help me here ? :(

    [@tacaswell edited to add markdown]

  10. tacaswell commented on Sep 4, 2018

    @tacaswell
    Member

    @wardakhan149 That question would probably be better on the mailing list (matplotlib-users@python.org see https://mail.python.org/mailman/listinfo/matplotlib-users ).

    Please include a minimal runnable example and the full traceback (it makes it way easier to help you if we can copy-paste reproduce the problem and see the full traceback you are seeing).

    Good luck!

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions