Skip to content

Hatches filling an empty color contour not saved in pdf #8431

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
andres0l1 opened this issue Apr 5, 2017 · 13 comments
Closed

Hatches filling an empty color contour not saved in pdf #8431

andres0l1 opened this issue Apr 5, 2017 · 13 comments
Milestone

Comments

@andres0l1
Copy link

I am trying to create a contour plot with the contours filled with hatches and no color. The following example works if I save it to .png but when I save it to .pdf the output is just the axis.
github

import numpy as np
import matplotlib.pyplot as plt



delta = 0.025

x = y = np.arange(-3.0, 3.01, delta)


X, Y = np.meshgrid(x, y)
Z1 = plt.mlab.bivariate_normal(X, Y, 1.0, 1.0, 0.0, 0.0)
Z2 = plt.mlab.bivariate_normal(X, Y, 1.5, 0.5, 1, 1)
Z = 10 * (Z1 - Z2)


levels=[0,1]
plt.contourf(X, Y, Z/X, 
                  levels,
                  #alpha=0.5,
                  colors='none', label='AGH',
                   hatches=['\\'])

plt.tight_layout()   

plt.savefig('GitHub.pdf')
plt.show()

I am using Matplotlib2.00 in Linux, installed from source.

@dstansby
Copy link
Member

dstansby commented Apr 9, 2017

Is the figure above what you expected to see when saving to a .pdf file? If so I think this is fixed on our master branch (we did a couple of patch fixes recently)

@andres0l1
Copy link
Author

Hi Dstansby! Thanks what should I do then? Update the library or what exactly? Thanks!

@tacaswell tacaswell added this to the 2.0.1 (next bug fix release) milestone Apr 10, 2017
@tacaswell
Copy link
Member

I can confirm that this works correctly on 2.0.x. I suggest installing from git for now, 2.0.1 will be out soon with this fix.

I have not checked, but I suspect this was fixed by f6b4a32 / #7976

@tacaswell
Copy link
Member

either the master branch or 2.0.x should work.

@andres0l1
Copy link
Author

Thanks a lot!!!

@tacaswell
Copy link
Member

Closing as resolved, keep an eye out for the next release.

@mschauer
Copy link

There are still problems on version 2.0.2 with saving hatches into pdfs. I am calling

fill_between(xx, upper, lower, edgecolor=darkcol, facecolor=lightcol, hatch="X")

@dstansby
Copy link
Member

2.1 is our latest release. Could you upgrade to that and let us know if there are still issues?

@mschauer
Copy link

I am now on 2.1.0 which fixes the problem. Thank you for the guidance.

@dstansby
Copy link
Member

No problem!

@mschauer
Copy link

hatch

There is still something going on while saving hatches to pdf. Left the pdf, right the result of show.
I am not sure if I am reaching the limits to mathplotlib, but to the left also the hatch became transparent.

import matplotlib.pyplot as plt
xx = [1,2,3,4,5]
upper = [3,3,3,3,4]
lower = [1,2,2,2,2]
plt.fill_between(xx, upper, lower, edgecolor="darkred", facecolor=[0.5,0.5,0.5,0.1], hatch="X", label="as")
plt.legend()
plt.savefig('ups.pdf')
plt.show()

@afvincent
Copy link
Contributor

The problem seems to occur with Acrobat Reader but not Evince. I tested the example from above with Matplotlib 2.0.0, 2.1.0 and from the master branch (on a Linux OS with Python 3.6): every time I get transparent hatches with Acrobat Reader (9.5.5) and correct hatches with Evince.

Worth opening a new dedicated issue?

@tacaswell
Copy link
Member

@afvincent yes please

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

No branches or pull requests

5 participants