Skip to content

Rasterizing patch changes filling of hatches in pdf backend #6228

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
claria opened this issue Mar 26, 2016 · 7 comments
Closed

Rasterizing patch changes filling of hatches in pdf backend #6228

claria opened this issue Mar 26, 2016 · 7 comments

Comments

@claria
Copy link

claria commented Mar 26, 2016

I want to plot a patch with the '*' hatch that is filled. The hatch is always filled when using
the agg backend but in the pdf backend only when it is rasterized.

As the legend artists do not use the rasterized prop (correct?), it is inconsistent.

mpl: 1.5.1, python 3.5.1, arch linux

Code to reproduce:

import matplotlib
import matplotlib.pyplot as plt

fig = plt.figure()
ax = fig.add_subplot(111)

# patch without hatching
patch1 = matplotlib.patches.Rectangle((0.5, 0.5), 1., 1., color='red', fill=False, hatch='*', label='patch1')
# patch with hatching
patch2 = matplotlib.patches.Rectangle((2.0, 0.5), 1., 1., color='blue', fill=False, hatch='*', rasterized=True, label='patch2')

ax.add_patch(patch1)
ax.add_patch(patch2)

ax.set_xlim(0., 3.5)
ax.set_ylim(0., 3)

ax.legend()


fig.savefig('asdf.png')
fig.savefig('asdf.pdf')

PNG output:

asdf

PDF output:

asdf pdf

@tacaswell
Copy link
Member

This may be addressed by #6198

@tacaswell tacaswell added this to the 2.0 (style change major release) milestone Mar 27, 2016
@tacaswell tacaswell modified the milestones: 2.1 (next point release), 2.0 (style change major release) Mar 27, 2016
@tacaswell
Copy link
Member

No, not fixed.

In pdf when an artist is rasterized that just means that artist is rendered via the Agg backend (the same as png) and then that is inserted into the pdf (hence why they match). We probably should propagate the rasterized flag to the legend. That isn't fool-proof as the artists maybe rasterized based on zorder as well, but better than nothing.

@tacaswell tacaswell modified the milestones: 2.1 (next point release), 2.0 (style change major release) Mar 27, 2016
@tacaswell
Copy link
Member

Of course doing that exposes #6227 ;)

@QuLogic
Copy link
Member

QuLogic commented Nov 8, 2016

So the legend is kind of unrelated here; it's that Agg renders with a filled hatch pattern when fill=False while PDF does not. Probably either one can be fixed directly rather easily, but which one is the expected behaviour here?

@tacaswell
Copy link
Member

I would go with the Agg behavior as 'correct'.

@QuLogic
Copy link
Member

QuLogic commented Nov 8, 2016

Well that's good, because PDF's the easier one to fix.

QuLogic added a commit to QuLogic/matplotlib that referenced this issue Nov 9, 2016
This matches behaviour with the Agg backend.

Fixes matplotlib#3023.
Fixes matplotlib#6228.
@NelleV
Copy link
Member

NelleV commented Nov 14, 2016

Closed in #7421

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

No branches or pull requests

4 participants