Skip to content

Commit 8956269

Browse files
Changing bar examples to tea and coffee (matplotlib#23590)
* changing bar examples to tea and coffee * changing stacked bar examples to tea and coffee * changing stacked bar examples to tea and coffee * changing stacked bar examples to tea and coffee * changing barchart examples to tea and coffee * changing stacked bar examples to tea and coffee * changing barchart examples to tea and coffee * changing bar unit examples from men and women to bream_fish length and parkki_fish length * changing bar unit examples from men and women to bream_fish length and parkki_fish length * changing bar unit examples from men and women to bream_fish length and parkki_fish length * changing bar unit examples from men and women to bream_fish length and parkki_fish length * changing bar unit examples from men and women to bream_fish length and parkki_fish length * changing bar unit examples from men and women to coffee and tea cup size * changing bar unit examples from men and women to coffee and tea cup size * changing bar unit examples from men and women to coffee and tea cup size * changing bar unit examples from men and women to coffee and tea cup size * changing stacked bar examples to tea and coffee * changing bar unit from men and women to coffee and tea cup size * changing bar label examples from men and women to coffee and tea * changing bar label examples from men and women to coffee and tea * changing bar label examples from men and women to coffee and tea * changing bar label examples from men and women to coffee and tea * changing bar unit from men and women to coffee and tea cup size * Update examples/units/bar_unit_demo.py Co-authored-by: Tim Hoffmann <[email protected]>
1 parent bdf83bb commit 8956269

File tree

4 files changed

+33
-33
lines changed

4 files changed

+33
-33
lines changed

examples/lines_bars_and_markers/bar_label_demo.py

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -21,25 +21,25 @@
2121
# Define the data
2222

2323
N = 5
24-
menMeans = (20, 35, 30, 35, -27)
25-
womenMeans = (25, 32, 34, 20, -25)
26-
menStd = (2, 3, 4, 1, 2)
27-
womenStd = (3, 5, 2, 3, 3)
24+
coffee_means = (20, 25, -10, 32, 10)
25+
tea_means = (30, 13, -14, 21, 17)
26+
coffee_std = (3, 2, 4, 1, 2)
27+
tea_std = (4, 3, 2, 3, 5)
2828
ind = np.arange(N) # the x locations for the groups
29-
width = 0.35 # the width of the bars: can also be len(x) sequence
29+
width = 0.25 # the width of the bars: can also be len(x) sequence
3030

3131
###############################################################################
3232
# Stacked bar plot with error bars
3333

3434
fig, ax = plt.subplots()
3535

36-
p1 = ax.bar(ind, menMeans, width, yerr=menStd, label='Men')
37-
p2 = ax.bar(ind, womenMeans, width,
38-
bottom=menMeans, yerr=womenStd, label='Women')
36+
p1 = ax.bar(ind, coffee_means, width, yerr=coffee_std, label='Coffee')
37+
p2 = ax.bar(ind, tea_means, width,
38+
bottom=coffee_means, yerr=tea_std, label='Tea')
3939

4040
ax.axhline(0, color='grey', linewidth=0.8)
4141
ax.set_ylabel('Scores')
42-
ax.set_title('Scores by group and gender')
42+
ax.set_title('Scores by group and their beverage choices')
4343
ax.set_xticks(ind, labels=['G1', 'G2', 'G3', 'G4', 'G5'])
4444
ax.legend()
4545

examples/lines_bars_and_markers/bar_stacked.py

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -5,28 +5,28 @@
55
66
This is an example of creating a stacked bar plot with error bars
77
using `~matplotlib.pyplot.bar`. Note the parameters *yerr* used for
8-
error bars, and *bottom* to stack the women's bars on top of the men's
8+
error bars, and *bottom* to stack the coffee's bars on top of the tea's
99
bars.
1010
"""
1111

1212
import matplotlib.pyplot as plt
1313

1414

1515
labels = ['G1', 'G2', 'G3', 'G4', 'G5']
16-
men_means = [20, 35, 30, 35, 27]
17-
women_means = [25, 32, 34, 20, 25]
18-
men_std = [2, 3, 4, 1, 2]
19-
women_std = [3, 5, 2, 3, 3]
20-
width = 0.35 # the width of the bars: can also be len(x) sequence
16+
tea_means = [20, 35, 30, 35, 27]
17+
coffee_means = [25, 32, 34, 20, 25]
18+
tea_std = [2, 3, 4, 1, 2]
19+
coffee_std = [3, 5, 5, 3, 3]
20+
width = 0.25 # the width of the bars: can also be len(x) sequence
2121

2222
fig, ax = plt.subplots()
2323

24-
ax.bar(labels, men_means, width, yerr=men_std, label='Men')
25-
ax.bar(labels, women_means, width, yerr=women_std, bottom=men_means,
26-
label='Women')
24+
ax.bar(labels, tea_means, width, yerr=tea_std, label='Tea')
25+
ax.bar(labels, coffee_means, width, yerr=coffee_std, bottom=tea_means,
26+
label='Coffee')
2727

2828
ax.set_ylabel('Scores')
29-
ax.set_title('Scores by group and gender')
29+
ax.set_title('Scores by group and beverage preferences')
3030
ax.legend()
3131

3232
plt.show()

examples/lines_bars_and_markers/barchart.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -12,19 +12,19 @@
1212

1313

1414
labels = ['G1', 'G2', 'G3', 'G4', 'G5']
15-
men_means = [20, 34, 30, 35, 27]
16-
women_means = [25, 32, 34, 20, 25]
15+
tea_means = [20, 34, 31, 35, 27]
16+
coffee_means = [25, 32, 34, 20, 25]
1717

1818
x = np.arange(len(labels)) # the label locations
19-
width = 0.35 # the width of the bars
19+
width = 0.25 # the width of the bars
2020

2121
fig, ax = plt.subplots()
22-
rects1 = ax.bar(x - width/2, men_means, width, label='Men')
23-
rects2 = ax.bar(x + width/2, women_means, width, label='Women')
22+
rects1 = ax.bar(x - width/2, tea_means, width, label='Tea')
23+
rects2 = ax.bar(x + width/2, coffee_means, width, label='Coffee')
2424

2525
# Add some text for labels, title and custom x-axis tick labels, etc.
2626
ax.set_ylabel('Scores')
27-
ax.set_title('Scores by group and gender')
27+
ax.set_title('Scores by group and beverage preferences')
2828
ax.set_xticks(x, labels)
2929
ax.legend()
3030

examples/units/bar_unit_demo.py

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -18,21 +18,21 @@
1818

1919

2020
N = 5
21-
men_means = [150*cm, 160*cm, 146*cm, 172*cm, 155*cm]
22-
men_std = [20*cm, 30*cm, 32*cm, 10*cm, 20*cm]
21+
tea_means = [15*cm, 10*cm, 8*cm, 12*cm, 5*cm]
22+
tea_std = [2*cm, 1*cm, 1*cm, 4*cm, 2*cm]
2323

2424
fig, ax = plt.subplots()
2525

2626
ind = np.arange(N) # the x locations for the groups
2727
width = 0.35 # the width of the bars
28-
ax.bar(ind, men_means, width, bottom=0*cm, yerr=men_std, label='Men')
28+
ax.bar(ind, tea_means, width, bottom=0*cm, yerr=tea_std, label='Tea')
2929

30-
women_means = (145*cm, 149*cm, 172*cm, 165*cm, 200*cm)
31-
women_std = (30*cm, 25*cm, 20*cm, 31*cm, 22*cm)
32-
ax.bar(ind + width, women_means, width, bottom=0*cm, yerr=women_std,
33-
label='Women')
30+
coffee_means = (14*cm, 19*cm, 7*cm, 5*cm, 10*cm)
31+
coffee_std = (3*cm, 5*cm, 2*cm, 1*cm, 2*cm)
32+
ax.bar(ind + width, coffee_means, width, bottom=0*cm, yerr=coffee_std,
33+
label='Coffee')
3434

35-
ax.set_title('Scores by group and gender')
35+
ax.set_title('Cup height by group and beverage choice')
3636
ax.set_xticks(ind + width / 2, labels=['G1', 'G2', 'G3', 'G4', 'G5'])
3737

3838
ax.legend()

0 commit comments

Comments
 (0)