Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit dc6802b

Browse files
committed
replaced np.random with concrete data
1 parent f8df71b commit dc6802b

File tree

1 file changed

+10
-13
lines changed

1 file changed

+10
-13
lines changed

examples/lines_bars_and_markers/stackplot_demo.py

Lines changed: 10 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -12,29 +12,26 @@
1212
import numpy as np
1313
import matplotlib.pyplot as plt
1414

15-
# Fixing random state for reproducibility
16-
np.random.seed(19680801)
15+
x = [1, 2, 3, 4, 5]
16+
y1 = [1, 1, 2, 3, 5]
17+
y2 = [0, 4, 2, 6, 8]
18+
y3 = [1, 3, 5, 7, 9]
1719

20+
y = np.vstack([y1, y2, y3])
1821

19-
def fnx():
20-
return np.random.randint(5, 50, 10)
21-
22-
23-
y = np.row_stack((fnx(), fnx(), fnx()))
24-
x = np.arange(10)
25-
26-
y1, y2, y3 = fnx(), fnx(), fnx()
22+
labels = ["fib", "evens", "odds"]
2723

2824
fig, ax = plt.subplots()
29-
ax.stackplot(x, y)
25+
ax.stackplot(x, y1, y2, y3, labels=labels)
26+
ax.legend(loc=2)
3027
plt.show()
3128

3229
fig, ax = plt.subplots()
33-
ax.stackplot(x, y1, y2, y3)
30+
ax.stackplot(x, y)
3431
plt.show()
3532

3633
###############################################################################
37-
# Here we'll show a slightly more complex example.
34+
# Here we show an example of making a streamgraph using stackplot
3835

3936

4037
def layers(n, m):

0 commit comments

Comments
 (0)