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

Commitd3ad76f

Browse files
committed
Automatically load PGF components
1 parente826b38 commitd3ad76f

File tree

3 files changed

+8
-10
lines changed

3 files changed

+8
-10
lines changed

‎lib/matplotlib/artist.py

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -677,16 +677,6 @@ def set_sketch_params(self, scale=None, length=None, randomness=None):
677677
"""
678678
Set the sketch parameters.
679679
680-
Requires the following preamble when using the PGF backend::
681-
682-
\\usepgfmodule{decorations}
683-
\\usepgflibrary{decorations.pathmorphing}
684-
685-
This also applies to PGF backend + PDF output, where this must be added
686-
to *pgf.preamble* manually. The PGF backend uses the *randomness*
687-
argument as a seed and not as described below. Pass the same seed to
688-
obtain the same random shape.
689-
690680
Parameters
691681
----------
692682
scale : float, optional
@@ -700,6 +690,9 @@ def set_sketch_params(self, scale=None, length=None, randomness=None):
700690
The scale factor by which the length is shrunken or
701691
expanded (default 16.0)
702692
693+
The PGF backend uses this argument as an RNG seed and not as
694+
described above. Using the same seed yields the same random shape.
695+
703696
.. ACCEPTS: (scale: float, length: float, randomness: float)
704697
"""
705698
ifscaleisNone:

‎lib/matplotlib/backends/backend_pgf.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -612,6 +612,9 @@ def _print_pgf_path(self, gc, path, transform, rgbFace=None):
612612
# same shape on multiple sketched lines
613613
scale,length,randomness=sketch_params
614614
ifscaleisnotNone:
615+
# PGF guarantees that repeated loading is a no-op
616+
writeln(self.fh,r"\usepgfmodule{decorations}")
617+
writeln(self.fh,r"\usepgflibrary{decorations.pathmorphing}")
615618
writeln(self.fh,r"\pgfkeys{/pgf/decoration/.cd, "
616619
f"segment length ={(length*f):f}in, "
617620
f"amplitude ={(scale*f):f}in}}")

‎lib/matplotlib/tests/test_backend_pgf.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -354,6 +354,8 @@ def test_sketch_params():
354354

355355
baseline=r"""\pgfpathmoveto{\pgfqpoint{0.375000in}{0.300000in}}%
356356
\pgfpathlineto{\pgfqpoint{2.700000in}{2.700000in}}%
357+
\usepgfmodule{decorations}%
358+
\usepgflibrary{decorations.pathmorphing}%
357359
\pgfkeys{/pgf/decoration/.cd, """ \
358360
r"""segment length = 0.300000in, amplitude = 0.050000in}%
359361
\pgfmathsetseed{42}%

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp