You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The hatch line width does not take effect when saving figure with the pgf backend. It is always drawn with a width of 1.
Code for reproduction
importmatplotlib.pyplotaspltimportmatplotlibasmplfrommatplotlib.backends.backend_pgfimportFigureCanvasPgfmpl.backend_bases.register_backend('pdf', FigureCanvasPgf)
mpl.rcParams['hatch.linewidth'] =0.1plt.bar(1, 1, color='white', edgecolor='black', hatch='/')
plt.savefig('hatch.pdf') # Hatch line width will be 1.plt.show() # Hatch line width will be 0.1 as expected.
Starting point for fix is likely RendererPgf.draw_path(). The linewidth is available via gc.get_hatch_linewidth(). Now we only need somebody who understands pgf.
Note: mpl.rcParams['hatch.color'] is also broken, but on a more fundamental level. It does not work for other renderers either.
Calling set_rasterized(True) on each bar element (individually) allows for me to use hatching without any issue. Not ideal but a good workaround for me.
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!
Activity
timhoffm commentedon Oct 26, 2019
Starting point for fix is likely
RendererPgf.draw_path(). The linewidth is available viagc.get_hatch_linewidth(). Now we only need somebody who understands pgf.Note:
mpl.rcParams['hatch.color']is also broken, but on a more fundamental level. It does not work for other renderers either.m-wells commentedon Mar 20, 2020
Calling
set_rasterized(True)on each bar element (individually) allows for me to use hatching without any issue. Not ideal but a good workaround for me.anntzer commentedon May 20, 2020
Looks like this is fixed by
Feel free to pick up the patch :)
pspiagicw commentedon Aug 24, 2021
Has this issue been fixed in some later PR ? If yes we should close this
timhoffm commentedon Aug 24, 2021
Likely not, otherwise the PR would be linked here. Have you any reason to believe this has been fixed?
pspiagicw commentedon Aug 25, 2021
The change needed seems to be a few lines , too low for a dedicated PR . If needed I can make a PR and close this issue.
timhoffm commentedon Aug 25, 2021
Developer resources are limited. Therefore also seemingly simple fixes may sometimes lie around or fall through the cracks.
You're are very welcome to provide a PR. Please provide a test if possible as well.
github-actions commentedon Jun 28, 2023
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!
QuLogic commentedon Jun 30, 2023
There is an open PR for this.
daeh commentedon Sep 13, 2024
Just adding enthusiastic support behind this issue being resolved. It's continuing to cause problems.
QuLogic commentedon Sep 3, 2026
This was fixed by #32254.