Skip to content

Commit 13b718f

Browse files
committed
Add 3.6.0 release candidate docs
1 parent ffb2934 commit 13b718f

File tree

7,417 files changed

+9979367
-0
lines changed

Some content is hidden

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

7,417 files changed

+9979367
-0
lines changed

3.6.0/Matplotlib.pdf

51.6 MB
Binary file not shown.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,79 @@
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# Line Collection\n\nPlotting lines with Matplotlib.\n\n`~matplotlib.collections.LineCollection` allows one to plot multiple\nlines on a figure. Below we show off some of its properties.\n"
19+
]
20+
},
21+
{
22+
"cell_type": "code",
23+
"execution_count": null,
24+
"metadata": {
25+
"collapsed": false
26+
},
27+
"outputs": [],
28+
"source": [
29+
"import matplotlib.pyplot as plt\nfrom matplotlib.collections import LineCollection\nfrom matplotlib import colors as mcolors\n\nimport numpy as np\n\n# In order to efficiently plot many lines in a single set of axes,\n# Matplotlib has the ability to add the lines all at once. Here is a\n# simple example showing how it is done.\n\nx = np.arange(100)\n# Here are many sets of y to plot vs. x\nys = x[:50, np.newaxis] + x[np.newaxis, :]\n\nsegs = np.zeros((50, 100, 2))\nsegs[:, :, 1] = ys\nsegs[:, :, 0] = x\n\n# Mask some values to test masked array support:\nsegs = np.ma.masked_where((segs > 50) & (segs < 60), segs)\n\n# We need to set the plot limits.\nfig, ax = plt.subplots()\nax.set_xlim(x.min(), x.max())\nax.set_ylim(ys.min(), ys.max())\n\n# *colors* is sequence of rgba tuples.\n# *linestyle* is a string or dash tuple. Legal string values are\n# solid|dashed|dashdot|dotted. The dash tuple is (offset, onoffseq) where\n# onoffseq is an even length tuple of on and off ink in points. If linestyle\n# is omitted, 'solid' is used.\n# See `matplotlib.collections.LineCollection` for more information.\ncolors = [mcolors.to_rgba(c)\n for c in plt.rcParams['axes.prop_cycle'].by_key()['color']]\n\nline_segments = LineCollection(segs, linewidths=(0.5, 1, 1.5, 2),\n colors=colors, linestyle='solid')\nax.add_collection(line_segments)\nax.set_title('Line collection with masked arrays')\nplt.show()"
30+
]
31+
},
32+
{
33+
"cell_type": "markdown",
34+
"metadata": {},
35+
"source": [
36+
"In order to efficiently plot many lines in a single set of axes,\nMatplotlib has the ability to add the lines all at once. Here is a\nsimple example showing how it is done.\n\n"
37+
]
38+
},
39+
{
40+
"cell_type": "code",
41+
"execution_count": null,
42+
"metadata": {
43+
"collapsed": false
44+
},
45+
"outputs": [],
46+
"source": [
47+
"N = 50\nx = np.arange(N)\n# Here are many sets of y to plot vs. x\nys = [x + i for i in x]\n\n# We need to set the plot limits, they will not autoscale\nfig, ax = plt.subplots()\nax.set_xlim(np.min(x), np.max(x))\nax.set_ylim(np.min(ys), np.max(ys))\n\n# colors is sequence of rgba tuples\n# linestyle is a string or dash tuple. Legal string values are\n# solid|dashed|dashdot|dotted. The dash tuple is (offset, onoffseq)\n# where onoffseq is an even length tuple of on and off ink in points.\n# If linestyle is omitted, 'solid' is used\n# See `matplotlib.collections.LineCollection` for more information\n\n# Make a sequence of (x, y) pairs.\nline_segments = LineCollection([np.column_stack([x, y]) for y in ys],\n linewidths=(0.5, 1, 1.5, 2),\n linestyles='solid')\nline_segments.set_array(x)\nax.add_collection(line_segments)\naxcb = fig.colorbar(line_segments)\naxcb.set_label('Line Number')\nax.set_title('Line Collection with mapped colors')\nplt.sci(line_segments) # This allows interactive changing of the colormap.\nplt.show()"
48+
]
49+
},
50+
{
51+
"cell_type": "markdown",
52+
"metadata": {},
53+
"source": [
54+
".. admonition:: References\n\n The use of the following functions, methods, classes and modules is shown\n in this example:\n\n - `matplotlib.collections`\n - `matplotlib.collections.LineCollection`\n - `matplotlib.cm.ScalarMappable.set_array`\n - `matplotlib.axes.Axes.add_collection`\n - `matplotlib.figure.Figure.colorbar` / `matplotlib.pyplot.colorbar`\n - `matplotlib.pyplot.sci`\n\n"
55+
]
56+
}
57+
],
58+
"metadata": {
59+
"kernelspec": {
60+
"display_name": "Python 3",
61+
"language": "python",
62+
"name": "python3"
63+
},
64+
"language_info": {
65+
"codemirror_mode": {
66+
"name": "ipython",
67+
"version": 3
68+
},
69+
"file_extension": ".py",
70+
"mimetype": "text/x-python",
71+
"name": "python",
72+
"nbconvert_exporter": "python",
73+
"pygments_lexer": "ipython3",
74+
"version": "3.10.4"
75+
}
76+
},
77+
"nbformat": 4,
78+
"nbformat_minor": 0
79+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
"""
2+
==========
3+
Hyperlinks
4+
==========
5+
6+
This example demonstrates how to set a hyperlinks on various kinds of elements.
7+
8+
This currently only works with the SVG backend.
9+
10+
"""
11+
12+
13+
import numpy as np
14+
import matplotlib.cm as cm
15+
import matplotlib.pyplot as plt
16+
17+
###############################################################################
18+
19+
fig = plt.figure()
20+
s = plt.scatter([1, 2, 3], [4, 5, 6])
21+
s.set_urls(['https://www.bbc.com/news', 'https://www.google.com/', None])
22+
fig.savefig('scatter.svg')
23+
24+
###############################################################################
25+
26+
fig = plt.figure()
27+
delta = 0.025
28+
x = y = np.arange(-3.0, 3.0, delta)
29+
X, Y = np.meshgrid(x, y)
30+
Z1 = np.exp(-X**2 - Y**2)
31+
Z2 = np.exp(-(X - 1)**2 - (Y - 1)**2)
32+
Z = (Z1 - Z2) * 2
33+
34+
im = plt.imshow(Z, interpolation='bilinear', cmap=cm.gray,
35+
origin='lower', extent=[-3, 3, -3, 3])
36+
37+
im.set_url('https://www.google.com/')
38+
fig.savefig('image.svg')
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
"""
2+
================
3+
pyplot animation
4+
================
5+
6+
Generating an animation by calling `~.pyplot.pause` between plotting commands.
7+
8+
The method shown here is only suitable for simple, low-performance use. For
9+
more demanding applications, look at the :mod:`.animation` module and the
10+
examples that use it.
11+
12+
Note that calling `time.sleep` instead of `~.pyplot.pause` would *not* work.
13+
"""
14+
15+
import matplotlib.pyplot as plt
16+
import numpy as np
17+
18+
np.random.seed(19680801)
19+
data = np.random.random((50, 50, 50))
20+
21+
fig, ax = plt.subplots()
22+
23+
for i in range(len(data)):
24+
ax.cla()
25+
ax.imshow(data[i])
26+
ax.set_title("frame {}".format(i))
27+
# Note that using time.sleep does *not* work here!
28+
plt.pause(0.1)
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,97 @@
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# Hatch style reference\n\nHatches can be added to most polygons in Matplotlib, including `~.Axes.bar`,\n`~.Axes.fill_between`, `~.Axes.contourf`, and children of `~.patches.Polygon`.\nThey are currently supported in the PS, PDF, SVG, OSX, and Agg backends. The WX\nand Cairo backends do not currently support hatching.\n\nSee also :doc:`/gallery/images_contours_and_fields/contourf_hatching` for\nan example using `~.Axes.contourf`, and\n:doc:`/gallery/shapes_and_collections/hatch_demo` for more usage examples.\n"
19+
]
20+
},
21+
{
22+
"cell_type": "code",
23+
"execution_count": null,
24+
"metadata": {
25+
"collapsed": false
26+
},
27+
"outputs": [],
28+
"source": [
29+
"import matplotlib.pyplot as plt\nfrom matplotlib.patches import Rectangle\n\nfig, axs = plt.subplots(2, 5, constrained_layout=True, figsize=(6.4, 3.2))\n\nhatches = ['/', '\\\\', '|', '-', '+', 'x', 'o', 'O', '.', '*']\n\n\ndef hatches_plot(ax, h):\n ax.add_patch(Rectangle((0, 0), 2, 2, fill=False, hatch=h))\n ax.text(1, -0.5, f\"' {h} '\", size=15, ha=\"center\")\n ax.axis('equal')\n ax.axis('off')\n\nfor ax, h in zip(axs.flat, hatches):\n hatches_plot(ax, h)"
30+
]
31+
},
32+
{
33+
"cell_type": "markdown",
34+
"metadata": {},
35+
"source": [
36+
"Hatching patterns can be repeated to increase the density.\n\n"
37+
]
38+
},
39+
{
40+
"cell_type": "code",
41+
"execution_count": null,
42+
"metadata": {
43+
"collapsed": false
44+
},
45+
"outputs": [],
46+
"source": [
47+
"fig, axs = plt.subplots(2, 5, constrained_layout=True, figsize=(6.4, 3.2))\n\nhatches = ['//', '\\\\\\\\', '||', '--', '++', 'xx', 'oo', 'OO', '..', '**']\n\nfor ax, h in zip(axs.flat, hatches):\n hatches_plot(ax, h)"
48+
]
49+
},
50+
{
51+
"cell_type": "markdown",
52+
"metadata": {},
53+
"source": [
54+
"Hatching patterns can be combined to create additional patterns.\n\n"
55+
]
56+
},
57+
{
58+
"cell_type": "code",
59+
"execution_count": null,
60+
"metadata": {
61+
"collapsed": false
62+
},
63+
"outputs": [],
64+
"source": [
65+
"fig, axs = plt.subplots(2, 5, constrained_layout=True, figsize=(6.4, 3.2))\n\nhatches = ['/o', '\\\\|', '|*', '-\\\\', '+o', 'x*', 'o-', 'O|', 'O.', '*-']\n\nfor ax, h in zip(axs.flat, hatches):\n hatches_plot(ax, h)"
66+
]
67+
},
68+
{
69+
"cell_type": "markdown",
70+
"metadata": {},
71+
"source": [
72+
".. admonition:: References\n\n The use of the following functions, methods, classes and modules is shown\n in this example:\n\n - `matplotlib.patches`\n - `matplotlib.patches.Rectangle`\n - `matplotlib.axes.Axes.add_patch`\n - `matplotlib.axes.Axes.text`\n\n"
73+
]
74+
}
75+
],
76+
"metadata": {
77+
"kernelspec": {
78+
"display_name": "Python 3",
79+
"language": "python",
80+
"name": "python3"
81+
},
82+
"language_info": {
83+
"codemirror_mode": {
84+
"name": "ipython",
85+
"version": 3
86+
},
87+
"file_extension": ".py",
88+
"mimetype": "text/x-python",
89+
"name": "python",
90+
"nbconvert_exporter": "python",
91+
"pygments_lexer": "ipython3",
92+
"version": "3.10.4"
93+
}
94+
},
95+
"nbformat": 4,
96+
"nbformat_minor": 0
97+
}

0 commit comments

Comments
 (0)