Skip to content

Commit 7f081e1

Browse files
AryanShekaoscargus
andauthored
Apply suggestions from code review
Co-authored-by: Oscar Gustafsson <oscar.gustafsson@gmail.com>
1 parent c9f4d44 commit 7f081e1

File tree

5 files changed

+17
-11
lines changed

5 files changed

+17
-11
lines changed
Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
seed for ``path.sketch`` will have a rolling(auto incrementing) behaviour
2-
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
1+
Seed for ``path.sketch`` will have a rolling (auto incrementing) behaviour
2+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
33

44
The seed for the internal Pseudo number generator will now have an auto incrementing behavior.
55
Hence every sub-figure will be sketched with a different seed and hence giving a more non repeating, random look.
66
Two figures sketched with the same parameters and same seed will look exactly the same.
77

8-
See 'What's new' on how to set a value to the seed and it's behaviour.
8+
See 'What's new' on how to set a value to the seed and its behaviour.

doc/users/next_whats_new/sketch_seed.rst

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,20 +2,23 @@
22
----------------------------------------------------
33

44
`~matplotlib.rcParams` now has a new parameter ``path.sketch_seed``.
5-
It's default value is 0 and accepted values are any non negative integer.
6-
This allows the user to set a value to the seed for the internal Pseudo number generator in one of three ways.
5+
Its default value is 0 and accepted values are any non negative integer.
6+
This allows the user to set a value to the seed for the internal pseudo random number generator in one of three ways.
77

88
1) Directly changing the rcParam:
9-
Eg. rcParams['path.sketch_seed']= 20
9+
10+
rcParams['path.sketch_seed'] = 20
1011

1112
2) Passing a value to the new *seed* parameter of `~matplotlib.pyplot.xkcd` function:
12-
Eg. plt.xkcd(seed=20)
13+
14+
plt.xkcd(seed=20)
1315

1416
3) Passing a value to the new *seed* parameter of `~matplotlib.artist.Artist.set_sketch_params` function:
15-
Eg. Artist.set_sketch_params(seed=20)
1617

17-
Note that using any one of these 3 methods changes the value of rcParams['path.sketch_seed'] variable.
18-
The seed will also have a rolling(auto incrementing) characteristic.
18+
Artist.set_sketch_params(seed=20)
19+
20+
Note that using any of these three methods changes the value of :rc:`path.sketch_seed`.
21+
The seed will also have a rolling (auto incrementing) characteristic.
1922
Two codes with the same parameters and same seed will be exactly same to one another.
2023

2124

lib/matplotlib/artist.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -706,6 +706,7 @@ def set_sketch_params(self, scale=None, length=None, randomness=None,
706706
seed : int, optional
707707
Seed for the internal pseudo-random number generator.
708708
For the same seed, the result will be exactly the same.
709+
709710
.. versionadded:: 3.8
710711
711712
.. ACCEPTS: (scale: float, length: float, randomness: float, seed: int)

lib/matplotlib/backend_bases.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1092,6 +1092,8 @@ def set_sketch_params(self, scale=None, length=None, randomness=None,
10921092
The scale factor by which the length is shrunken or expanded.
10931093
seed : int, optional
10941094
Seed for the internal pseudo-random number generator.
1095+
1096+
.. versionadded:: 3.8
10951097
"""
10961098

10971099
if seed is not None:

lib/matplotlib/rcsetup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -555,7 +555,7 @@ def validate_sketch(s):
555555
def validate_sketch_seed(s):
556556
s = validate_int(s)
557557

558-
if ((s >= 0)):
558+
if s >= 0:
559559
return s
560560
else:
561561
raise ValueError("seed must be a non negative integer")

0 commit comments

Comments
 (0)