Skip to content

Several hatching improvements #7421

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

Merged
merged 5 commits into from
Nov 14, 2016
Merged

Conversation

QuLogic
Copy link
Member

@QuLogic QuLogic commented Nov 7, 2016

This produces some more consistency for hatches across multiple backends.

@QuLogic QuLogic added this to the 2.0 (style change major release) milestone Nov 7, 2016
@tacaswell
Copy link
Member

Would be good if @mdboom could look at this, but 👍

Holding off on merging this until @QuLogic has looked at the hatch origin issue seems reasonable to me to avoid having to re-generate the test images again.

The hatch buffer was created at 72 pixels, with the assumption that that
is the "unit square" (1in*1in). However, with default DPI increased to
100, that buffer is actually too small, causing hatching to be denser
than it should be. On test images where the DPI was set really low, the
hatching was less dense than it should be.

Fixes matplotlib#4108.
Doesn't change anything; just makes it consistent with what it actually
is.

Also, remove comment about DPI-dependence, because hatching should not
be DPI dependent.
Also, clean up some redundancies; 72 -> sidelen and the setpattern
operator simplifies setting the pattern.
Agg uses top-left as origin, while PDF/PS use bottom-left. A vertical
shift by the page height fixes that.

See example in matplotlib#4108.
This matches behaviour with the Agg backend.

Fixes matplotlib#3023.
Fixes matplotlib#6228.
@QuLogic QuLogic changed the title [WIP] Generate rasterized hatching at correct DPI. [MRG] Several hatching improvements Nov 9, 2016
@QuLogic
Copy link
Member Author

QuLogic commented Nov 9, 2016

I've fixed the hatching origin in the PDF and PS backends, and also made a few other improvements in the PS backend. See the description for an updated explanation.

Note, a lot of the PS and PDF backends don't really seem to be tested... Could add the test based on the related issues, but not sure where the best place is.

@tacaswell tacaswell changed the title [MRG] Several hatching improvements [MRG+1] Several hatching improvements Nov 9, 2016
@NelleV NelleV added the Release critical For bugs that make the library unusable (segfaults, incorrect plots, etc) and major regressions. label Nov 10, 2016
@NelleV NelleV merged commit 571d7ef into matplotlib:v2.x Nov 14, 2016
@QuLogic QuLogic deleted the hatch-dpi-density branch November 14, 2016 21:50
@QuLogic QuLogic changed the title [MRG+1] Several hatching improvements Several hatching improvements Nov 14, 2016
@NelleV
Copy link
Member

NelleV commented Nov 14, 2016

Thanks for the patch!

@jkokorian
Copy link

How can I set the hatch line color when using fill_between? I am only able to set the background color using the color kwarg. edgecolor doesn't appear to do anything...

@tacaswell
Copy link
Member

@jkokorian sorry meant #7976

@jkokorian
Copy link

thanks!

@andres0l1
Copy link

andres0l1 commented Apr 3, 2017

Hi, Sorry I am a bit new to Python but I am having the same problems as in: #3023 I have re-installed Matplotlib and updated it but my hatches still do not show up when I save my plot as .pdf
Thanks!

@tacaswell
Copy link
Member

@andres0l1 Can you please open a new issue with a minimal example of what is not working for you?

@andres0l1
Copy link

Sure I will!

@@ -322,6 +322,7 @@ def create_hatch(self, hatch):
self._convert_path(Path.hatch(hatch), Affine2D().scale(sidelen),
simplify=False))
self._pswriter.write("""\
fill
Copy link
Contributor

@mkvoya mkvoya Jan 2, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Anyone knows whether it is okay to write "fill" here? I deleted the "fill" and the hatch works on v3.0.2. The issue is described in #8289.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Or shell we use the shfill command?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What is the difference between fill and shfill?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@tacaswell sorry, I just skimmed the spec of EPS and found that shfill (shading fill, which "paints the shape and color shading described by a shading dictionary, subject to the current clipping path") seems not related.

But I do have tried multiple manual fixes on the generated eps file and had the following findings:

  1. Simply removing the "fill" can solve the issue in Hatching in EPS figures doesn't show up in Preview on MacOS X with Matplotlib 2.0 #8289. But when we draw with "*", the stars are not filled with colors, which breaks Rasterizing patch changes filling of hatches in pdf backend #6228.
  2. Surrounding the fill with gsave and grestore, also fixes Hatching in EPS figures doesn't show up in Preview on MacOS X with Matplotlib 2.0 #8289, but the result of Rasterizing patch changes filling of hatches in pdf backend #6228 is as follow.

image

I'm not familiar with the eps format, but hope the information is helpful.

@mkvoya mkvoya mentioned this pull request Aug 16, 2019
6 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backend: agg backend: pdf backend: ps Release critical For bugs that make the library unusable (segfaults, incorrect plots, etc) and major regressions.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants