10000 Move some pylab examples to other folders · matplotlib/matplotlib@083578c · GitHub
[go: up one dir, main page]

Skip to content

Commit 083578c

Browse files
committed
Move some pylab examples to other folders
1 parent 8ae0dbf commit 083578c

File tree

9 files changed

+60
-68
lines changed

9 files changed

+60
-68
lines changed
File renamed without changes.
Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
"""
2+
=============
3+
Barchart Demo
4+
=============
5+
6+
Bar chart demo with pairs of bars grouped for easy comparison.
7+
"""
8+
import numpy as np
9+
import matplotlib.pyplot as plt
10+
11+
12+
n_groups = 5
13+
14+
means_men = (20, 35, 30, 35, 27)
15+
std_men = (2, 3, 4, 1, 2)
16+
17+
means_women = (25, 32, 34, 20, 25)
18+
std_women = (3, 5, 2, 3, 3)
19+
20+
fig, ax = plt.subplots()
21+
22+
index = np.arange(n_groups)
23+
bar_width = 0.35
24+
25+
opacity = 0.4
26+
error_config = {'ecolor': '0.3'}
27+
28+
rects1 = plt.bar(index, means_men, bar_width,
29+
alpha=opacity,
30+
color='b',
31+
yerr=std_men,
32+
error_kw=error_config,
33+
label='Men')
34+
35+
rects2 = plt.bar(index + bar_width, means_women, bar_width,
36+
alpha=opacity,
37+
color='r',
38+
yerr=std_women,
39+
error_kw=error_config,
40+
label='Women')
41+
42+
plt.xlabel('Group')
43+
plt.ylabel('Scores')
44+
plt.title('Scores by group and gender')
45+
plt.xticks(index + bar_width / 2, ('A', 'B', 'C', 'D', 'E'))
46+
plt.legend()
47+
48+
plt.tight_layout()
49+
plt.show()

examples/statistics/barchart_demo.py renamed to examples/lines_bars_and_markers/barchart_demo2.py

Lines changed: 11 additions & 55 deletions
Original file line numberDiff line numberDiff line change
@@ -1,69 +1,25 @@
11
"""
2-
=============
3-
Barchart Demo
4-
=============
2+
==============
3+
Barchart Demo2
4+
==============
55
6-
Bar charts of many shapes and sizes with Matplotlib.
6+
Thanks Josh Hemann for the example
77
8-
Bar charts are useful for visualizing counts, or summary statistics
9-
with error bars. These examples show a few ways to do this with Matplotlib.
8+
This examples comes from an application in which grade school gym
9+
teachers wanted to be able to show parents how their child did across
10+
a handful of fitness tests, and importantly, relative to how other
11+
children did. To extract the plotting code for demo purposes, we'll
12+
just make up some data for little Johnny Doe...
1013
1114
"""
12-
13-
# Credit: Josh Hemann
14-
1515
import numpy as np
1616
import matplotlib.pyplot as plt
1717
from matplotlib.ticker import MaxNLocator
1818
from collections import namedtuple
1919

20+
# Fixing random state for reproducibility
21+
np.random.seed(19680801)
2022

21-
n_groups = 5
22-
23-
means_men = (20, 35, 30, 35, 27)
24-
std_men = (2, 3, 4, 1, 2)
25-
26-
means_women = (25, 32, 34, 20, 25)
27-
std_women = (3, 5, 2, 3, 3)
28-
29-
fig, ax = plt.subplots()
30-
31-
index = np.arange(n_groups)
32-
bar_width = 0.35
33-
34-
opacity = 0.4
35-
error_config = {'ecolor': '0.3'}
36-
37-
rects1 = plt.bar(index, means_men, bar_width,
38-
alpha=opacity,
39-
color='b',
40-
yerr=std_men,
41-
error_kw=error_config,
42-
label='Men')
43-
44-
rects2 = plt.bar(index + bar_width, means_women, bar_width,
45-
alpha=opacity,
46-
color='r',
47-
yerr=std_women,
48-
error_kw=error_config,
49-
label='Women')
50-
51-
plt.xlabel('Group')
52-
plt.ylabel('Scores')
53-
plt.title('Scores by group and gender')
54-
plt.xticks(index + bar_width / 2, ('A', 'B', 'C', 'D', 'E'))
55-
plt.legend()
56-
57-
plt.tight_layout()
58-
plt.show()
59-
60-
61-
###############################################################################
62-
# This example comes from an application in which grade school gym
63-
# teachers wanted to be able to show parents how their child did across
64-
# a handful of fitness tests, and importantly, relative to how other
65-
# children did. To extract the plotting code for demo purposes, we'll
66-
# just make up some data for little Johnny Doe...
6723

6824
Student = namedtuple('Student', ['name', 'grade', 'gender'])
6925
Score = namedtuple('Score', ['score', 'percentile'])

examples/pylab_examples/README

Lines changed: 0 additions & 13 deletions
This file was deleted.

0 commit comments

Comments
 (0)
0