Skip to content

Commit 2acf945

Browse files
oscargusanntzer
andcommitted
Fix hatch linewidth in PGF
Co-authored-by: Antony Lee <anntzer.lee@gmail.com>
1 parent 68c78c9 commit 2acf945

File tree

3 files changed

+15
-1
lines changed

3 files changed

+15
-1
lines changed

lib/matplotlib/backends/backend_pgf.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -477,6 +477,9 @@ def draw_path(self, gc, path, transform, rgbFace=None):
477477
r"{\pgfqpoint{0in}{0in}}{\pgfqpoint{1in}{1in}}")
478478
_writeln(self.fh, r"\pgfusepath{clip}")
479479
scale = mpl.transforms.Affine2D().scale(self.dpi)
480+
lw = (mpl.rcParams["hatch.linewidth"]
481+
* mpl_pt_to_in * latex_in_to_pt)
482+
_writeln(self.fh, r"\pgfsetlinewidth{%fpt}" % lw)
480483
self._print_pgf_path(None, gc.get_hatch_path(), scale)
481484
self._pgf_path_draw(stroke=True)
482485
_writeln(self.fh, r"\end{pgfscope}")
Binary file not shown.

lib/matplotlib/tests/test_backend_pgf.py

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,8 @@
1111
import matplotlib.pyplot as plt
1212
from matplotlib.testing import _has_tex_package, _check_for_pgf
1313
from matplotlib.testing.compare import compare_images, ImageComparisonFailure
14-
from matplotlib.backends.backend_pgf import PdfPages, _tex_escape
14+
from matplotlib.backends.backend_pgf import (
15+
FigureCanvasPgf, PdfPages, _tex_escape)
1516
from matplotlib.testing.decorators import (
1617
_image_directories, check_figures_equal, image_comparison)
1718
from matplotlib.testing._markers import (
@@ -365,3 +366,13 @@ def test_sketch_params():
365366
# \pgfdecoratecurrentpath must be after the path definition and before the
366367
# path is used (\pgfusepath)
367368
assert baseline in buf
369+
370+
371+
@needs_pgf_xelatex
372+
@pytest.mark.backend('pgf')
373+
@image_comparison(['hatch_linewidth'], extensions=['pdf'])
374+
def test_pgf_hatch_linewidth():
375+
mpl.backend_bases.register_backend('pdf', FigureCanvasPgf)
376+
mpl.rcParams['hatch.linewidth'] = 0.1
377+
378+
plt.bar(1, 1, color='white', edgecolor='black', hatch='/')

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy