8000 Replace random values by hard-coded numbers in plot-types ... · matplotlib/matplotlib@714636e · GitHub
[go: up one dir, main page]

Skip to content

Commit 714636e

Browse files
committed
Replace random values by hard-coded numbers in plot-types ...
... for the cases where we have only very few random numbers. This makes the code a bit simpler, because we do not have to seed. Also, a list of hard-coded numbers is slightly simpler to grasp compared to a rng function. This is partly also in anticipation of the switch to numpy's rng generator classes. While conceptually superior, they are a bit more verbose and introduce the additional local variable `rng` (IMHO this is the benefit and the downside: It explicitly ties the rng state to the local context -> clarity. But OTOH the user is bothered with this local state even if it's not important to them - like in our examples.)
1 parent e7fd79f commit 714636e

File tree

3 files changed

+3
-6
lines changed

3 files changed

+3
-6
lines changed

galleries/plot_types/basic/bar.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,8 @@
1111
plt.style.use('_mpl-gallery')
1212

1313
# make data:
14-
np.random.seed(3)
1514
x = 0.5 + np.arange(8)
16-
y = np.random.uniform(2, 7, len(x))
15+
y = [4.8, 5.5, 3.5, 4.6, 6.5, 6.6, 2.6, 3.0]
1716

1817
# plot
1918
fig, ax = plt.subplots()

galleries/plot_types/basic/stem.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,8 @@
1111
plt.style.use('_mpl-gallery')
1212

1313
# make data
14-
np.random.seed(3)
1514
x = 0.5 + np.arange(8)
16-
y = np.random.uniform(2, 7, len(x))
15+
y = [4.8, 5.5, 3.5, 4.6, 6.5, 6.6, 2.6, 3.0]
1716

1817
# plot
1918
fig, ax = plt.subplots()

galleries/plot_types/basic/step.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,8 @@
1111
plt.style.use('_mpl-gallery')
1212

1313
# make data
14-
np.random.seed(3)
1514
x = 0.5 + np.arange(8)
16-
y = np.random.uniform(2, 7, len(x))
15+
y = [4.8, 5.5, 3.5, 4.6, 6.5, 6.6, 2.6, 3.0]
1716

1817
# plot
1918
fig, ax = plt.subplots()

0 commit comments

Comments
 (0)
0