Skip to content

bar / hist : gap between first bar and other bars with lw=0.0 #4602

Closed

Description

@damiendr

I like to make solid bar plots without lines around each bar, eg:

plt.hist(data, fc="gray", lw=0.0, alpha=0.5)

Problem: the first bar does not exactly line up with the other bars. There is a slight misalignment visible on the right and bottom edges. Depending on the window size this shows either as a white gap or a darker overlap (visible because alpha=0.5).

The other bars are all properly lined up.

Confirmed both in the notebook inline mode and the QT backend on OSX.
matplotlib.__version__ = '1.4.3'

Steps to reproduce:

import matplotlib.pylab as plt
import numpy as np
plt.figure()
plt.hist(np.random.uniform(0.0, 1.0, size=1000), fc="gray", lw=0.0, alpha=0.5)
plt.show()

Then resize the window and observe.

Activity

  1. damiendr commented on Jul 8, 2015

    @damiendr
    Author

    Examples:
    gap
    overlap

  2. tacaswell commented on Jul 8, 2015

    @tacaswell
    Member

    That is...interesting...

    You might be interested in #4433 which I hope to get merged for the upcoming release but you can pull the relevant function out (There is a copy-pastable function for this at #643 (comment)).

  3. tacaswell commented on Jul 8, 2015

    @tacaswell
    Member

    I bet this is related to #4584 .

  4. jenshnielsen commented on Jul 8, 2015

    @jenshnielsen
    Member

    I agree that it is related to #4584 I can reproduce the issue with Agg based backends whereas it looks different with GTK3Cairo and WX

  5. added this to the milestone on Aug 31, 2015
  6. cimarronm commented on Oct 18, 2015

    @cimarronm
    Contributor

    This is the same issue as #4212. See that issue for more details on what is happening. @damiendr, you can use the following as a workaround:

    _, _, collections = plt.hist(np.random.uniform(0.0, 1.0, size=1000), fc="gray", lw=0.0, alpha=0.5)
    collections[0].set_snap(True)
  7. efiring commented on Sep 6, 2016

    @efiring
    Member

    Closed by #6887

  8. modified the milestones: , on Sep 6, 2016
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