Skip to content
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

Matplotlib does not display hatching when rendering to pdf in fill_between #2229

Merged
merged 2 commits into from
Sep 5, 2013

Conversation

mdboom
Copy link
Member

@mdboom mdboom commented Aug 12, 2013

Hi,

using fill_between with hatching and specifying a edgecolor and color='none' should result in edge and hatch plotted with edgecolor

While the edge is plotted, the hatch is not plotted at all (or not visible) when output is a pdf.
This works for png output.

I assume this is a bug, since it does not occur for the fill() method

PNG
test
PDF
testpdf

Working example:

import matplotlib.pyplot as plt

plt.fill_between([1,2,3],[0.5,0.5,0.5],[1.5,1.5,1.5], hatch='/', color='none', edgecolor='blue')

plt.savefig('test.png')
plt.savefig('test.pdf'')

@claria claria closed this Jul 18, 2013
@claria claria reopened this Jul 18, 2013
@WeatherGod
Copy link
Member

Which version of matplotlib are you using? IIRC, this was a bug that was fixed after 1.2.1.

@claria
Copy link
Author

claria commented Jul 18, 2013

Found this issue on 1.2.1 but i checked it now on 1.3.0rc2 and there it exists as well

import matplotlib
matplotlib.version
'1.3.0rc2'

Sorry for missing the version in initial post

@pelson
Copy link
Member

pelson commented Aug 12, 2013

Confirmed. I suspect there is some logic in the pdf code which checks for a "none" color and then skips the fill section (which included hatching)...

@claria
Copy link
Author

claria commented Aug 12, 2013

You are right. In matplotlib/lib/matplotlib/backends/backend_pdf.py, there is nothing filled when no facecolor is specified. I did a quick test by specifying filled manually in this case, and the result looks as expected.

def draw_path_collection(self, gc, master_transform, paths, all_transforms,
                         offsets, offsetTrans, facecolors, edgecolors,
                         linewidths, linestyles, antialiaseds, urls,
                         offset_position):
    facecolors = np.asarray(facecolors)
    edgecolors = np.asarray(edgecolors)

    if not len(facecolors):
        filled = False
    else:
    ..........

@ghost ghost assigned mdboom Aug 12, 2013
mdboom added a commit to mdboom/matplotlib that referenced this pull request Aug 12, 2013
@mdboom
Copy link
Member

mdboom commented Aug 12, 2013

@claria: Could you test the attached patch?

@claria
Copy link
Author

claria commented Aug 12, 2013

Applying this patch against 1.3.0 fixes the issue for me. Thanks alot

@pelson
Copy link
Member

pelson commented Aug 13, 2013

Change looks good to me. I'm guessing the travis test failures are not a coincidence, would you mind looking into this and I'd be happy to merge.

@mdboom
Copy link
Member

mdboom commented Sep 4, 2013

Rebased and unit tests (hopefully) fixed.

mdboom added a commit that referenced this pull request Sep 5, 2013
Matplotlib does not display hatching when rendering to pdf in fill_between
@mdboom mdboom merged commit 7662361 into matplotlib:v1.3.x Sep 5, 2013
@mdboom mdboom deleted the pdf/no-hatching branch August 7, 2014 13:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants