Skip to content

Adding hatches changes face color #14639

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
SMZ70 opened this issue Jun 26, 2019 · 8 comments
Closed

Adding hatches changes face color #14639

SMZ70 opened this issue Jun 26, 2019 · 8 comments
Labels
backend: pdf keep Items to be ignored by the “Stale” Github Action status: downstream fix required

Comments

@SMZ70
Copy link

SMZ70 commented Jun 26, 2019

Bug report

Bug summary

Adding hatches results in a change in the face color of bars. The problem occurs when saved as PDF. Everything is ok with png.

Code for reproduction

import matplotlib.pyplot as plt

fig, ax = plt.subplots()
ax.barh(2, 4, edgecolor='black', facecolor='green', alpha=0.3)
ax.barh(3, 4, edgecolor='black', facecolor='green', hatch='///', alpha=0.3)
fig.savefig('hbarplot.pdf')
fig.savefig('hbarplot.png')

Actual outcome

image

Expected outcome

The plot in the pdf file to be the same as the one in png file.

Matplotlib version

  • Operating system: Windows 10
  • Matplotlib version: 3.0.3, conda, default
  • Matplotlib backend (print(matplotlib.get_backend())): Qt5Agg or module://ipykernel.pylab.backend_inline (problem occurs with both)
  • Python version: 3.7
@jklymak
Copy link
Member

jklymak commented Jun 26, 2019

Can you try a range of PDF viewers? This works fine on Apple Preview, and Adobe Acrobat.

@timhoffm
Copy link
Member

timhoffm commented Jun 27, 2019

Generated with 3.1: hbarplot.pdf

This file is displayed correctly in Okular and Adobe Reader.

@SMZ70 you can download this file and cross-check with your PDF viewer.

@SMZ70
Copy link
Author

SMZ70 commented Jun 27, 2019

Can you try a range of PDF viewers? This works fine on Apple Preview, and Adobe Acrobat.

You're right. The problem is with Foxit Reader. Thanks!

@SMZ70
Copy link
Author

SMZ70 commented Jun 27, 2019

Generated with 3.1: hbarplot.pdf

This file is displayed correctly in Okular and Adobe Reader.

@SMZ70 you can download this file and cross-check with your PDF viewer.

The file looks fine in Adobe Reader, but the problem exists with Foxit Reader. There must be something wrong with the viewer. Thanks!

@anntzer
Copy link
Contributor

anntzer commented Jun 27, 2019

The pdf is also misdisplayed by chromium.
OTOH mplcairo generates a pdf that chromium reads fine.

@ImportanceOfBeingErnest
Copy link
Member

There are continuously problems with matplotlib generated output on different pdf viewers.
One thing I found to often work nicely is to save pdfs via svg and convert to pdf with inkscape.

def savepdfviasvg(fig, name, **kwargs):
    import subprocess
    fig.savefig(name+".svg", format="svg", **kwargs)
    incmd = ["inkscape", name+".svg", "--export-pdf={}.pdf".format(name),
             "--export-pdf-version=1.5"] #"--export-ignore-filters",
    subprocess.check_output(incmd)

    
savepdfviasvg(fig, "hatchtestconv")

@timhoffm
Copy link
Member

It's unclear if the PDF we generate is broken but handled gracefully by some viewers, or if we comply with the spec and the viewers are buggy. But to find out, somebody with experience in the PDF specification would be required.

@github-actions
Copy link

This issue has been marked "inactive" because it has been 365 days since the last comment. If this issue is still present in recent Matplotlib releases, or the feature request is still wanted, please leave a comment and this label will be removed. If there are no updates in another 30 days, this issue will be automatically closed, but you are free to re-open or create a new issue if needed. We value issue reports, and this procedure is meant to help us resurface and prioritize issues that have not been addressed yet, not make them disappear. Thanks for your help!

@github-actions github-actions bot added the status: inactive Marked by the “Stale” Github Action label Jun 21, 2023
@github-actions github-actions bot added the status: closed as inactive Issues closed by the "Stale" Github Action. Please comment on any you think should still be open. label Jul 24, 2023
@github-actions github-actions bot closed this as not planned Won't fix, can't repro, duplicate, stale Jul 24, 2023
@anntzer anntzer added keep Items to be ignored by the “Stale” Github Action and removed status: inactive Marked by the “Stale” Github Action status: closed as inactive Issues closed by the "Stale" Github Action. Please comment on any you think should still be open. labels Jul 24, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backend: pdf keep Items to be ignored by the “Stale” Github Action status: downstream fix required
Projects
None yet
Development

No branches or pull requests

6 participants