Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit2acf945

Browse files
oscargusanntzer
andcommitted
Fix hatch linewidth in PGF
Co-authored-by: Antony Lee <anntzer.lee@gmail.com>
1 parent68c78c9 commit2acf945

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
importmatplotlib.pyplotasplt
1212
frommatplotlib.testingimport_has_tex_package,_check_for_pgf
1313
frommatplotlib.testing.compareimportcompare_images,ImageComparisonFailure
14-
frommatplotlib.backends.backend_pgfimportPdfPages,_tex_escape
14+
frommatplotlib.backends.backend_pgfimport (
15+
FigureCanvasPgf,PdfPages,_tex_escape)
1516
frommatplotlib.testing.decoratorsimport (
1617
_image_directories,check_figures_equal,image_comparison)
1718
frommatplotlib.testing._markersimport (
@@ -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
assertbaselineinbuf
369+
370+
371+
@needs_pgf_xelatex
372+
@pytest.mark.backend('pgf')
373+
@image_comparison(['hatch_linewidth'],extensions=['pdf'])
374+
deftest_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)

[8]ページ先頭

©2009-2025 Movatter.jp