8000 addressing comments · matplotlib/matplotlib@0347764 · GitHub
[go: up one dir, main page]

Skip to content

Commit 0347764

Browse files
committed
addressing comments
1 parent aa88fae commit 0347764

File tree

2 files changed

+18
-3
lines changed

2 files changed

+18
-3
lines changed

examples/lines_bars_and_markers/categorical_variables.py

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,13 +13,27 @@
1313
"""
1414
import matplotlib.pyplot as plt
1515

16-
names = ['group_a', 'group_b', 'group_c']
17-
values = [1, 10, 100]
16+
data = {'apples': 10, 'oranges': 15, 'lemons': 5, 'limes': 20}
17+
names = list(data.keys())
18+
values = list(data.values())
1819

19-
fig, axs = plt.subplots(1, 3, figsize=(9, 3))
20+
fig, axs = plt.subplots(1, 3, figsize=(9, 3), sharey=True)
2021
axs[0].bar(names, values)
2122
axs[1].scatter(names, values)
2223
axs[2].plot(names, values)
2324
fig.suptitle('Categorical Plotting')
2425

26+
27+
###############################################################################
28+
# This works on both axes:
29+
30+
cat = ["bored", "happy", "bored", "bored", "happy", "bored"]
31+
dog = ["happy", "happy", "happy", "happy", "bored", "bored"]
32+
activity = ["combing", "drinking", "feeding", "napping", "playing", "washing"]
33+
34+
fig, ax = plt.subplots()
35+
ax.plot(activity, dog, label="dog")
36+
ax.plot(activity, cat, label="cat")
37+
ax.legend()
38+
2539
plt.show()

tutorials/01_introductory/sample_plots.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -386,6 +386,7 @@
386386
import matplotlib.pyplot as plt
387387
import numpy as np
388388

389+
np.random.seed(19680801)
389390
data = np.random.randn(2, 100)
390391

391392
fig, axs = plt.subplots(2, 2, figsize=(5, 5))

0 commit comments

Comments
 (0)
0