Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
39980d4
changing bar examples to tea and coffee
SourajitaDewasi Aug 9, 2022
dd83fd4
changing stacked bar examples to tea and coffee
SourajitaDewasi Aug 10, 2022
b73e8ff
changing stacked bar examples to tea and coffee
SourajitaDewasi Aug 10, 2022
96cab12
changing stacked bar examples to tea and coffee
SourajitaDewasi Aug 13, 2022
397141b
changing barchart examples to tea and coffee
SourajitaDewasi Aug 13, 2022
c9a098d
changing stacked bar examples to tea and coffee
SourajitaDewasi Aug 13, 2022
ff0d0e0
changing barchart examples to tea and coffee
SourajitaDewasi Aug 13, 2022
9dcfa49
changing bar unit examples from men and women to bream_fish length an…
SourajitaDewasi Aug 13, 2022
1eff97f
changing bar unit examples from men and women to bream_fish length an…
SourajitaDewasi Aug 13, 2022
a9bcdcf
changing bar unit examples from men and women to bream_fish length an…
SourajitaDewasi Aug 13, 2022
edbaa83
changing bar unit examples from men and women to bream_fish length an…
SourajitaDewasi Aug 13, 2022
c0f5d1f
changing bar unit examples from men and women to bream_fish length an…
SourajitaDewasi Aug 13, 2022
3f8cb4d
changing bar unit examples from men and women to coffee and tea cup size
SourajitaDewasi Aug 14, 2022
706ccd3
changing bar unit examples from men and women to coffee and tea cup size
SourajitaDewasi Aug 14, 2022
7538ebc
changing bar unit examples from men and women to coffee and tea cup size
SourajitaDewasi Aug 14, 2022
1e19265
changing bar unit examples from men and women to coffee and tea cup size
SourajitaDewasi Aug 14, 2022
35207a2
changing stacked bar examples to tea and coffee
SourajitaDewasi Aug 15, 2022
1c7dca2
changing bar unit from men and women to coffee and tea cup size
SourajitaDewasi Aug 15, 2022
6fc4e49
changing bar label examples from men and women to coffee and tea
SourajitaDewasi Aug 15, 2022
13d61d0
changing bar label examples from men and women to coffee and tea
SourajitaDewasi Aug 15, 2022
9e6a79d
changing bar label examples from men and women to coffee and tea
SourajitaDewasi Aug 16, 2022
49f8a6a
changing bar label examples from men and women to coffee and tea
SourajitaDewasi Aug 16, 2022
cf3733a
changing bar unit from men and women to coffee and tea cup size
SourajitaDewasi Aug 16, 2022
b8bf772
Update examples/units/bar_unit_demo.py
timhoffm Aug 27, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 9 additions & 9 deletions examples/lines_bars_and_markers/bar_label_demo.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,25 +21,25 @@
# Define the data

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

###############################################################################
# Stacked bar plot with error bars

fig, ax = plt.subplots()

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

ax.axhline(0, color='grey', linewidth=0.8)
ax.set_ylabel('Scores')
ax.set_title('Scores by group and gender')
ax.set_title('Scores by group and their beverage choices')

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I just realized that the example has been semantically weird already before. The stacked bar suggests that the quantity is summed up from both subgroups, and the errorbar indicates that within each subgroup the quantity is averaged. I cannot come up with a reasonable quantity for "Scores" that would actually work this way.

Second, before there were groups and inside these groups we distinguished by gender. This is something everybody is familiar with. Splitting a group up by beverage choice and scoring these subgroups is possible but an even more weird experiment.

I think we have two choices:
a) Come up with something completely new
b) Or accept that the plot is not semantically meaningful, merge and do something a) later.

@story645 what do you think?

@story645 story645 Aug 26, 2022 •

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ugh, I want to be okay with merging something that's not semantically meaningful 'cause @SourajitaDewasi worked so much on this, but I hear you that the semantics being off might be a distraction that will make the example harder to follow.
Keeping it simple, maybe change the underlying pivot table to

(caffeinated, tea), (decaffeinated, tea), (caffeinated, coffee), (decaffeinated, coffee) and the y axis is like #avg drink rating (1-5) so the example is basically a made up rating of what type of drink folks prefer.

ETA: cup height probably works just as well, or average amount drunk or the like.

Alternatively, palmer penguins is being used a lot to illustrate aggregated visualizations, and we can probably keep this example pretty small if what we store in the example is the pivot table made from it https://allisonhorst.github.io/palmerpenguins/

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would be fine with merging as-is as an improvement, with the suggestion below, and have a follow up either a) removing the example, or b) reworking it to include penguins or other good ideas.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok, let's take this as is (suggestion below committed) so that we can git this in 3.6. And let's think about how we can further improve later.

ax.set_xticks(ind, labels=['G1', 'G2', 'G3', 'G4', 'G5'])
ax.legend()

Expand Down
20 changes: 10 additions & 10 deletions examples/lines_bars_and_markers/bar_stacked.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,28 +5,28 @@

This is an example of creating a stacked bar plot with error bars
using `~matplotlib.pyplot.bar`. Note the parameters *yerr* used for
error bars, and *bottom* to stack the women's bars on top of the men's
error bars, and *bottom* to stack the coffee's bars on top of the tea's
bars.
"""

import matplotlib.pyplot as plt


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

fig, ax = plt.subplots()

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

ax.set_ylabel('Scores')
ax.set_title('Scores by group and gender')
ax.set_title('Scores by group and beverage preferences')
ax.legend()

plt.show()
12 changes: 6 additions & 6 deletions examples/lines_bars_and_markers/barchart.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,19 +12,19 @@


labels = ['G1', 'G2', 'G3', 'G4', 'G5']
men_means = [20, 34, 30, 35, 27]
women_means = [25, 32, 34, 20, 25]
tea_means = [20, 34, 31, 35, 27]
coffee_means = [25, 32, 34, 20, 25]

x = np.arange(len(labels)) # the label locations
width = 0.35 # the width of the bars
width = 0.25 # the width of the bars

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

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

Expand Down
16 changes: 8 additions & 8 deletions examples/units/bar_unit_demo.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,21 +18,21 @@


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

fig, ax = plt.subplots()

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

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

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

ax.legend()
Expand Down