FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

[Bug]: .eps greyscale hatching of patches when lw=0 · Issue #22792 · matplotlib/matplotlib · GitHub

Repository navigation

[Bug]: .eps greyscale hatching of patches when lw=0 #22792

Closed

Description

Bug summary

Export to .eps-format of patches that are filled with a colored hatch pattern appear in greyscale color when linewidth of the patch is set to zero.

Code for reproduction

import matplotlib.pyplot as plt
from matplotlib.patches import Ellipse

ax = plt.gca()
ax.add_patch(Ellipse((0, 0), 1, 1, hatch='/', facecolor='none', edgecolor='r', linewidth=0))

plt.savefig(r"E:\mwe.png")
plt.savefig(r"E:\mwe.eps")

plt.show()

Actual outcome

.eps-file converted to .png-format using GIMP 2.10.30

Expected outcome

.png-file exported by matplotlib

.eps-file exported by matplotlib with linewidth > 0 converted to .png-format using GIMP 2.10.30

Additional information

It happens when linewidth is set to zero.

I don't know if it worked in earlier versions.

I had a look on the eps-commands in the file. (I don't know anything about eps-format.) It is most likely due to certain eps-commands being removed when linewidth is set to zero, including a command for the line color.

Operating system

Windows 10

Matplotlib Version

3.5.1

Matplotlib Backend

TkAgg

Python version

3.9.10

Jupyter version

n/a

Installation

pip

Activity

  1. jklymak commented on Apr 6, 2022

    Member

    Thanks for the helpful bug summary and looking into the possible cause (which sounds reasonable). Not sure who will step up to fix this, but it does seem like somehow the colours are not getting set. Perhaps see if pdf works?

  2. topper91 commented on Apr 6, 2022

    Author

    thx for the quick response. pdf-export works just fine.

  3. oscargus commented on Apr 6, 2022

    Member

    A quick diff between the mwe here and one with setting linewidth to 0.1.

    (base) lnx00073 [~]> diff mwe.eps mwe2.eps 
    2c2
    < %%Title: mwe.eps
    ---
    > %%Title: mwe2.eps
    4c4
    < %%CreationDate: Wed Apr  6 16:08:50 2022
    ---
    > %%CreationDate: Wed Apr  6 16:09:28 2022
    242a243,247
    > 0.100 setlinewidth
    > 0 setlinejoin
    > 0 setlinecap
    > [] 0 setdash
    > 1.000 0.000 0.000 setrgbcolor
    291a297
    > stroke
    295,296d300
    < 0 setlinecap
    < [] 0 setdash
    

    I'd say that it is these lines that are not executing:

    if mightstroke:
    self.set_linewidth(gc.get_linewidth())
    self.set_linejoin(gc.get_joinstyle())
    self.set_linecap(gc.get_capstyle())
    self.set_linedash(*gc.get_dashes())
    self.set_color(*gc.get_rgb()[:3])
    as mightstroke is False (as linewidth is 0).

    Moving the color-setting out of the if-clause seems to solve this problem, but I am not sure if it causes other issues.

    Edit:

    I don't know if it worked in earlier versions.

    That code has been around for 14 years, so it is not a recent regression. Hence, this should probably go into 3.6.

  4. added this to the v3.6.0 milestone on Apr 6, 2022
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


      Back | FazBrowse Home | New Git URL