Skip to content

Commit 9937f63

Browse files
committed
deploy 3.1.0 docs
1 parent 425762c commit 9937f63

File tree

12,779 files changed

+1482626
-201851
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

12,779 files changed

+1482626
-201851
lines changed

3.1.0/Matplotlib.tex

+231,960
Large diffs are not rendered by default.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
{
2+
"cells": [
3+
{
4+
"cell_type": "code",
5+
"execution_count": null,
6+
"metadata": {
7+
"collapsed": false
8+
},
9+
"outputs": [],
10+
"source": [
11+
"%matplotlib inline"
12+
]
13+
},
14+
{
15+
"cell_type": "markdown",
16+
"metadata": {},
17+
"source": [
18+
"\n# Scatter Star Poly\n\n\nCreate multiple scatter plots with different\nstar symbols.\n"
19+
]
20+
},
21+
{
22+
"cell_type": "code",
23+
"execution_count": null,
24+
"metadata": {
25+
"collapsed": false
26+
},
27+
"outputs": [],
28+
"source": [
29+
"import numpy as np\nimport matplotlib.pyplot as plt\n\n# Fixing random state for reproducibility\nnp.random.seed(19680801)\n\n\nx = np.random.rand(10)\ny = np.random.rand(10)\nz = np.sqrt(x**2 + y**2)\n\nplt.subplot(321)\nplt.scatter(x, y, s=80, c=z, marker=\">\")\n\nplt.subplot(322)\nplt.scatter(x, y, s=80, c=z, marker=(5, 0))\n\nverts = np.array([[-1, -1], [1, -1], [1, 1], [-1, -1]])\nplt.subplot(323)\nplt.scatter(x, y, s=80, c=z, marker=verts)\n\nplt.subplot(324)\nplt.scatter(x, y, s=80, c=z, marker=(5, 1))\n\nplt.subplot(325)\nplt.scatter(x, y, s=80, c=z, marker='+')\n\nplt.subplot(326)\nplt.scatter(x, y, s=80, c=z, marker=(5, 2))\n\nplt.show()"
30+
]
31+
}
32+
],
33+
"metadata": {
34+
"kernelspec": {
35+
"display_name": "Python 3",
36+
"language": "python",
37+
"name": "python3"
38+
},
39+
"language_info": {
40+
"codemirror_mode": {
41+
"name": "ipython",
42+
"version": 3
43+
},
44+
"file_extension": ".py",
45+
"mimetype": "text/x-python",
46+
"name": "python",
47+
"nbconvert_exporter": "python",
48+
"pygments_lexer": "ipython3",
49+
"version": "3.7.3"
50+
}
51+
},
52+
"nbformat": 4,
53+
"nbformat_minor": 0
54+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
"""
2+
=======================================
3+
Different ways of specifying error bars
4+
=======================================
5+
6+
Errors can be specified as a constant value (as shown in
7+
`errorbar_demo.py`). However, this example demonstrates
8+
how they vary by specifying arrays of error values.
9+
10+
If the raw ``x`` and ``y`` data have length N, there are two options:
11+
12+
Array of shape (N,):
13+
Error varies for each point, but the error values are
14+
symmetric (i.e. the lower and upper values are equal).
15+
16+
Array of shape (2, N):
17+
Error varies for each point, and the lower and upper limits
18+
(in that order) are different (asymmetric case)
19+
20+
In addition, this example demonstrates how to use log
21+
scale with error bars.
22+
"""
23+
24+
import numpy as np
25+
import matplotlib.pyplot as plt
26+
27+
# example data
28+
x = np.arange(0.1, 4, 0.5)
29+
y = np.exp(-x)
30+
31+
# example error bar values that vary with x-position
32+
error = 0.1 + 0.2 * x
33+
34+
fig, (ax0, ax1) = plt.subplots(nrows=2, sharex=True)
35+
ax0.errorbar(x, y, yerr=error, fmt='-o')
36+
ax0.set_title('variable, symmetric error')
37+
38+
# error bar values w/ different -/+ errors that
39+
# also vary with the x-position
40+
lower_error = 0.4 * error
41+
upper_error = error
42+
asymmetric_error = [lower_error, upper_error]
43+
44+
ax1.errorbar(x, y, xerr=asymmetric_error, fmt='o')
45+
ax1.set_title('variable, asymmetric error')
46+
ax1.set_yscale('log')
47+
plt.show()
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
{
2+
"cells": [
3+
{
4+
"cell_type": "code",
5+
"execution_count": null,
6+
"metadata": {
7+
"collapsed": false
8+
},
9+
"outputs": [],
10+
"source": [
11+
"%matplotlib inline"
12+
]
13+
},
14+
{
15+
"cell_type": "markdown",
16+
"metadata": {},
17+
"source": [
18+
"\n# Agg Buffer\n\n\nUse backend agg to access the figure canvas as an RGB string and then\nconvert it to an array and pass it to Pillow for rendering.\n"
19+
]
20+
},
21+
{
22+
"cell_type": "code",
23+
"execution_count": null,
24+
"metadata": {
25+
"collapsed": false
26+
},
27+
"outputs": [],
28+
"source": [
29+
"import numpy as np\n\nfrom matplotlib.backends.backend_agg import FigureCanvasAgg\nimport matplotlib.pyplot as plt\n\nplt.plot([1, 2, 3])\n\ncanvas = plt.get_current_fig_manager().canvas\n\nagg = canvas.switch_backends(FigureCanvasAgg)\nagg.draw()\ns, (width, height) = agg.print_to_buffer()\n\n# Convert to a NumPy array.\nX = np.frombuffer(s, np.uint8).reshape((height, width, 4))\n\n# Pass off to PIL.\nfrom PIL import Image\nim = Image.frombytes(\"RGBA\", (width, height), s)\n\n# Uncomment this line to display the image using ImageMagick's `display` tool.\n# im.show()"
30+
]
31+
}
32+
],
33+
"metadata": {
34+
"kernelspec": {
35+
"display_name": "Python 3",
36+
"language": "python",
37+
"name": "python3"
38+
},
39+
"language_info": {
40+
"codemirror_mode": {
41+
"name": "ipython",
42+
"version": 3
43+
},
44+
"file_extension": ".py",
45+
"mimetype": "text/x-python",
46+
"name": "python",
47+
"nbconvert_exporter": "python",
48+
"pygments_lexer": "ipython3",
49+
"version": "3.7.3"
50+
}
51+
},
52+
"nbformat": 4,
53+
"nbformat_minor": 0
54+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
{
2+
"cells": [
3+
{
4+
"cell_type": "code",
5+
"execution_count": null,
6+
"metadata": {
7+
"collapsed": false
8+
},
9+
"outputs": [],
10+
"source": [
11+
"%matplotlib inline"
12+
]
13+
},
14+
{
15+
"cell_type": "markdown",
16+
"metadata": {},
17+
"source": [
18+
"\n# Animated line plot\n\n"
19+
]
20+
},
21+
{
22+
"cell_type": "code",
23+
"execution_count": null,
24+
"metadata": {
25+
"collapsed": false
26+
},
27+
"outputs": [],
28+
"source": [
29+
"import numpy as np\nimport matplotlib.pyplot as plt\nimport matplotlib.animation as animation\n\nfig, ax = plt.subplots()\n\nx = np.arange(0, 2*np.pi, 0.01)\nline, = ax.plot(x, np.sin(x))\n\n\ndef init(): # only required for blitting to give a clean slate.\n line.set_ydata([np.nan] * len(x))\n return line,\n\n\ndef animate(i):\n line.set_ydata(np.sin(x + i / 100)) # update the data.\n return line,\n\n\nani = animation.FuncAnimation(\n fig, animate, init_func=init, interval=2, blit=True, save_count=50)\n\n# To save the animation, use e.g.\n#\n# ani.save(\"movie.mp4\")\n#\n# or\n#\n# from matplotlib.animation import FFMpegWriter\n# writer = FFMpegWriter(fps=15, metadata=dict(artist='Me'), bitrate=1800)\n# ani.save(\"movie.mp4\", writer=writer)\n\nplt.show()"
30+
]
31+
}
32+
],
33+
"metadata": {
34+
"kernelspec": {
35+
"display_name": "Python 3",
36+
"language": "python",
37+
"name": "python3"
38+
},
39+
"language_info": {
40+
"codemirror_mode": {
41+
"name": "ipython",
42+
"version": 3
43+
},
44+
"file_extension": ".py",
45+
"mimetype": "text/x-python",
46+
"name": "python",
47+
"nbconvert_exporter": "python",
48+
"pygments_lexer": "ipython3",
49+
"version": "3.7.3"
50+
}
51+
},
52+
"nbformat": 4,
53+
"nbformat_minor": 0
54+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
"""
2+
=================
3+
Fancytextbox Demo
4+
=================
5+
6+
"""
7+
import matplotlib.pyplot as plt
8+
9+
plt.text(0.6, 0.7, "eggs", size=50, rotation=30.,
10+
ha="center", va="center",
11+
bbox=dict(boxstyle="round",
12+
ec=(1., 0.5, 0.5),
13+
fc=(1., 0.8, 0.8),
14+
)
15+
)
16+
17+
plt.text(0.55, 0.6, "spam", size=50, rotation=-25.,
18+
ha="right", va="top",
19+
bbox=dict(boxstyle="square",
20+
ec=(1., 0.5, 0.5),
21+
fc=(1., 0.8, 0.8),
22+
)
23+
)
24+
25+
plt.show()
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,151 @@
1+
"""
2+
===============================
3+
Resizing axes with tight layout
4+
===============================
5+
6+
`~.figure.Figure.tight_layout` attempts to resize subplots in
7+
a figure so that there are no overlaps between axes objects and labels
8+
on the axes.
9+
10+
See :doc:`/tutorials/intermediate/tight_layout_guide` for more details and
11+
:doc:`/tutorials/intermediate/constrainedlayout_guide` for an alternative.
12+
13+
"""
14+
15+
import matplotlib.pyplot as plt
16+
import itertools
17+
import warnings
18+
19+
20+
fontsizes = itertools.cycle([8, 16, 24, 32])
21+
22+
23+
def example_plot(ax):
24+
ax.plot([1, 2])
25+
ax.set_xlabel('x-label', fontsize=next(fontsizes))
26+
ax.set_ylabel('y-label', fontsize=next(fontsizes))
27+
ax.set_title('Title', fontsize=next(fontsizes))
28+
29+
30+
###############################################################################
31+
32+
fig, ax = plt.subplots()
33+
example_plot(ax)
34+
plt.tight_layout()
35+
36+
###############################################################################
37+
38+
fig, ((ax1, ax2), (ax3, ax4)) = plt.subplots(nrows=2, ncols=2)
39+
example_plot(ax1)
40+
example_plot(ax2)
41+
example_plot(ax3)
42+
example_plot(ax4)
43+
plt.tight_layout()
44+
45+
###############################################################################
46+
47+
fig, (ax1, ax2) = plt.subplots(nrows=2, ncols=1)
48+
example_plot(ax1)
49+
example_plot(ax2)
50+
plt.tight_layout()
51+
52+
###############################################################################
53+
54+
fig, (ax1, ax2) = plt.subplots(nrows=1, ncols=2)
55+
example_plot(ax1)
56+
example_plot(ax2)
57+
plt.tight_layout()
58+
59+
###############################################################################
60+
61+
fig, axes = plt.subplots(nrows=3, ncols=3)
62+
for row in axes:
63+
for ax in row:
64+
example_plot(ax)
65+
plt.tight_layout()
66+
67+
###############################################################################
68+
69+
fig = plt.figure()
70+
71+
ax1 = plt.subplot(221)
72+
ax2 = plt.subplot(223)
73+
ax3 = plt.subplot(122)
74+
75+
example_plot(ax1)
76+
example_plot(ax2)
77+
example_plot(ax3)
78+
79+
plt.tight_layout()
80+
81+
###############################################################################
82+
83+
fig = plt.figure()
84+
85+
ax1 = plt.subplot2grid((3, 3), (0, 0))
86+
ax2 = plt.subplot2grid((3, 3), (0, 1), colspan=2)
87+
ax3 = plt.subplot2grid((3, 3), (1, 0), colspan=2, rowspan=2)
88+
ax4 = plt.subplot2grid((3, 3), (1, 2), rowspan=2)
89+
90+
example_plot(ax1)
91+
example_plot(ax2)
92+
example_plot(ax3)
93+
example_plot(ax4)
94+
95+
plt.tight_layout()
96+
97+
plt.show()
98+
99+
###############################################################################
100+
101+
fig = plt.figure()
102+
103+
gs1 = fig.add_gridspec(3, 1)
104+
ax1 = fig.add_subplot(gs1[0])
105+
ax2 = fig.add_subplot(gs1[1])
106+
ax3 = fig.add_subplot(gs1[2])
107+
108+
example_plot(ax1)
109+
example_plot(ax2)
110+
example_plot(ax3)
111+
112+
gs1.tight_layout(fig, rect=[None, None, 0.45, None])
113+
114+
gs2 = fig.add_gridspec(2, 1)
115+
ax4 = fig.add_subplot(gs2[0])
116+
ax5 = fig.add_subplot(gs2[1])
117+
118+
example_plot(ax4)
119+
example_plot(ax5)
120+
121+
with warnings.catch_warnings():
122+
# gs2.tight_layout cannot handle the subplots from the first gridspec
123+
# (gs1), so it will raise a warning. We are going to match the gridspecs
124+
# manually so we can filter the warning away.
125+
warnings.simplefilter("ignore", UserWarning)
126+
gs2.tight_layout(fig, rect=[0.45, None, None, None])
127+
128+
# now match the top and bottom of two gridspecs.
129+
top = min(gs1.top, gs2.top)
130+
bottom = max(gs1.bottom, gs2.bottom)
131+
132+
gs1.update(top=top, bottom=bottom)
133+
gs2.update(top=top, bottom=bottom)
134+
135+
plt.show()
136+
137+
#############################################################################
138+
#
139+
# ------------
140+
#
141+
# References
142+
# """"""""""
143+
#
144+
# The use of the following functions and methods is shown in this example:
145+
146+
import matplotlib
147+
matplotlib.pyplot.tight_layout
148+
matplotlib.figure.Figure.tight_layout
149+
matplotlib.figure.Figure.add_gridspec
150+
matplotlib.figure.Figure.add_subplot
151+
matplotlib.pyplot.subplot2grid

0 commit comments

Comments
 (0)