Skip to content

Commit 435ac6f

Browse files
committed
New doc gallery for plot_types
1 parent bd7df78 commit 435ac6f

31 files changed

+656
-2
lines changed

doc/_templates/layout.html

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@
5656
<ul>
5757
<li><a href="{{ pathto('users/installing') }}">Installation</a></li>
5858
<li><a href="{{ pathto('contents') }}">Documentation</a></li>
59+
<li><a href="{{ pathto('plot_types/index') }}">Plot Types</a></li>
5960
<li><a href="{{ pathto('gallery/index') }}">Examples</a></li>
6061
<li><a href="{{ pathto('tutorials/index') }}">Tutorials</a></li>
6162
<li><a href="{{ pathto('devel/index') }}">Contributing</a></li>

doc/conf.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -151,9 +151,9 @@ def _check_dependencies():
151151

152152
# Sphinx gallery configuration
153153
sphinx_gallery_conf = {
154-
'examples_dirs': ['../examples', '../tutorials'],
154+
'examples_dirs': ['../examples', '../tutorials', '../plot_types'],
155155
'filename_pattern': '^((?!sgskip).)*$',
156-
'gallery_dirs': ['gallery', 'tutorials'],
156+
'gallery_dirs': ['gallery', 'tutorials', 'plot_types'],
157157
'doc_module': ('matplotlib', 'mpl_toolkits'),
158158
'reference_url': {
159159
'matplotlib': None,
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
# from the Matplotlib cheatsheet as used in our gallery:
2+
3+
4+
axes.facecolor: white
5+
axes.edgecolor: black
6+
axes.linewidth: 1.0
7+
axes.grid: True
8+
axes.axisbelow: True # grid/ticks are below elements (e.g., lines, text)
9+
10+
xtick.color: 555555
11+
xtick.direction: out
12+
13+
ytick.color: 555555
14+
ytick.direction: out
15+
16+
grid.color: b0b0b0
17+
grid.linewidth: 0.7
18+
grid.linestyle: - # solid line
19+
20+
figure.facecolor: white
21+
figure.figsize: 2, 2
22+
# make it so the axes labels don't show up. Obviously
23+
# not good style for any quantitative analysis:
24+
figure.subplot.left: 0.01
25+
figure.subplot.right: 0.99
26+
figure.subplot.bottom: 0.01
27+
figure.subplot.top: 0.99
28+

plot_types/A_basic/README.rst

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
.. _basic_plots:
2+
3+
Basic
4+
-----
5+
6+
Basic plot types, usually x versus y.

plot_types/A_basic/a_plot.py

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
"""
2+
======================
3+
plot([X], Y, [fmt]...)
4+
======================
5+
"""
6+
7+
import matplotlib.pyplot as plt
8+
import numpy as np
9+
10+
# make data
11+
X = np.linspace(0, 10, 100)
12+
Y = 4 + 2 * np.sin(2 * X)
13+
14+
# plot
15+
with plt.style.context('cheatsheet_gallery'):
16+
fig, ax = plt.subplots()
17+
18+
ax.plot(X, Y, color="C1", linewidth=2.0)
19+
20+
ax.set_xlim(0, 8), ax.set_xticks(np.arange(1, 8))
21+
ax.set_ylim(0, 8), ax.set_yticks(np.arange(1, 8))
22+
23+
plt.show()

plot_types/A_basic/b_scatter.py

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
"""
2+
==================
3+
scatter(X, Y, ...)
4+
==================
5+
"""
6+
import matplotlib.pyplot as plt
7+
import numpy as np
8+
9+
# make the data
10+
np.random.seed(3)
11+
X = 4 + np.random.normal(0, 1.25, 24)
12+
Y = 4 + np.random.normal(0, 1.25, len(X))
13+
14+
# plot
15+
with plt.style.context('cheatsheet_gallery'):
16+
fig, ax = plt.subplots()
17+
18+
ax.scatter(X, Y, 20, zorder=10,
19+
edgecolor="none", facecolor="C1", linewidth=0.25)
20+
21+
ax.set_xlim(0, 8), ax.set_xticks(np.arange(1, 8))
22+
ax.set_ylim(0, 8), ax.set_yticks(np.arange(1, 8))
23+
24+
plt.show()

plot_types/A_basic/c_bar.py

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
"""
2+
======================
3+
bar[h](x, height, ...)
4+
======================
5+
"""
6+
import matplotlib.pyplot as plt
7+
import numpy as np
8+
9+
# make data:
10+
np.random.seed(3)
11+
X = 0.5 + np.arange(8)
12+
Y = np.random.uniform(2, 7, len(X))
13+
14+
# plot
15+
with plt.style.context('cheatsheet_gallery'):
16+
fig, ax = plt.subplots()
17+
18+
ax.bar(X, Y, bottom=0, width=1, edgecolor="white",
19+
facecolor="C1", linewidth=0.7)
20+
21+
ax.set_xlim(0, 8), ax.set_xticks(np.arange(1, 8))
22+
ax.set_ylim(0, 8), ax.set_yticks(np.arange(1, 8))
23+
24+
plt.show()

plot_types/A_basic/d_stem.py

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
"""
2+
=================
3+
stem([x], y, ...)
4+
=================
5+
"""
6+
import matplotlib.pyplot as plt
7+
import numpy as np
8+
9+
# make data
10+
np.random.seed(3)
11+
X = 0.5 + np.arange(8)
12+
Y = np.random.uniform(2, 7, len(X))
13+
14+
# plot
15+
with plt.style.context('cheatsheet_gallery'):
16+
fig, ax = plt.subplots()
17+
18+
ax.stem(X, Y, bottom=0, linefmt="C1-", markerfmt="C1d")
19+
20+
ax.set_xlim(0, 8), ax.set_xticks(np.arange(1, 8))
21+
ax.set_ylim(0, 8), ax.set_yticks(np.arange(1, 8))
22+
plt.show()

plot_types/A_basic/e_step.py

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
"""
2+
=====================
3+
step(x, y, where=...)
4+
=====================
5+
"""
6+
import matplotlib.pyplot as plt
7+
import numpy as np
8+
9+
# make data
10+
np.random.seed(3)
11+
X = 0.5 + np.arange(8)
12+
Y = np.random.uniform(2, 7, len(X))
13+
14+
# plot
15+
with plt.style.context('cheatsheet_gallery'):
16+
fig, ax = plt.subplots()
17+
18+
ax.step(X, Y, color="C1", linewidth=2.5)
19+
20+
ax.set_xlim(0, 8), ax.set_xticks(np.arange(1, 8))
21+
ax.set_ylim(0, 8), ax.set_yticks(np.arange(1, 8))
22+
plt.show()

plot_types/A_basic/f_pie.py

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
"""
2+
====================
3+
pie(X, explode, ...)
4+
====================
5+
"""
6+
import matplotlib as mpl
7+
import matplotlib.pyplot as plt
8+
import numpy as np
9+
10+
# make data
11+
X = [1, 2, 3, 4]
12+
colors = np.zeros((len(X), 4))
13+
colors[:] = mpl.colors.to_rgba("C1")
14+
colors[:, 3] = np.linspace(0.25, 0.75, len(X))
15+
16+
# plot
17+
with plt.style.context('cheatsheet_gallery'):
18+
fig, ax = plt.subplots()
19+
20+
ax.pie(X, colors=["white"]*len(X), radius=3, center=(4, 4),
21+
wedgeprops={"linewidth": 1, "edgecolor": "white"}, frame=True)
22+
ax.pie(X, colors=colors, radius=3, center=(4, 4),
23+
wedgeprops={"linewidth": 1, "edgecolor": "white"}, frame=True)
24+
25+
ax.set_xlim(0, 8), ax.set_xticks(np.arange(1, 8))
26+
ax.set_ylim(0, 8), ax.set_yticks(np.arange(1, 8))
27+
28+
plt.show()

0 commit comments

Comments
 (0)