@@ -337,3 +337,38 @@ def test_minus_signs_with_tex(fig_test, fig_ref, texsystem):
337337 mpl .rcParams ["pgf.texsystem" ] = texsystem
338338 fig_test .text (.5 , .5 , "$-1$" )
339339 fig_ref .text (.5 , .5 , "$\N{MINUS SIGN} 1$" )
340+
341+
342+ @pytest .mark .backend ("pgf" )
343+ def test_sketch_params ():
344+ fig , ax = plt .subplots (figsize = [3 , 3 ])
345+ ax .set_xticks ([])
346+ ax .set_yticks ([])
347+ ax .set_frame_on (False )
348+ handle = ax .plot ([0 , 1 ])[0 ]
349+ handle .set_sketch_params (scale = 5 , length = 30 , randomness = 42 )
350+
351+ with BytesIO () as fd :
352+ fig .savefig (fd , format = 'pgf' )
353+ buf = fd .getvalue ().decode ()
354+
355+ baseline = r"""\begin{pgfscope}%
356+ \pgfpathrectangle{\pgfqpoint{0.375000in}{0.300000in}}""" \
357+ r"""{\pgfqpoint{2.325000in}{2.400000in}}%
358+ \pgfusepath{clip}%
359+ \pgfsetrectcap%
360+ \pgfsetroundjoin%
361+ \pgfsetlinewidth{1.003750pt}%
362+ \definecolor{currentstroke}{rgb}{0.000000,0.000000,1.000000}%
363+ \pgfsetstrokecolor{currentstroke}%
364+ \pgfsetdash{}{0pt}%
365+ \pgfpathmoveto{\pgfqpoint{0.375000in}{0.300000in}}%
366+ \pgfpathlineto{\pgfqpoint{2.700000in}{2.700000in}}%
367+ \pgfkeys{/pgf/decoration/.cd, """ \
368+ r"""segment length = 0.300000in, amplitude = 0.050000in}%
369+ \pgfmathsetseed{42}%
370+ \pgfdecoratecurrentpath{random steps}%
371+ \pgfusepath{stroke}%
372+ \end{pgfscope}%"""
373+ # check that \pgfkeys{/pgf/decoration/.cd, ...} is in path definition
374+ assert baseline in buf
0 commit comments