Skip to content

Commit 5d2fb87

Browse files
committed
Update docs for v3.8.4
1 parent 8fd2775 commit 5d2fb87

File tree

9,049 files changed

+4407649
-2
lines changed

Some content is hidden

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

9,049 files changed

+4407649
-2
lines changed

Diff for: 3.8.4/Matplotlib.pdf

52.5 MB
Binary file not shown.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
{
2+
"cells": [
3+
{
4+
"cell_type": "markdown",
5+
"metadata": {},
6+
"source": [
7+
"\n# Plotting multiple lines with a LineCollection\n\nMatplotlib can efficiently draw multiple lines at once using a\n`~.LineCollection`, as showcased below.\n"
8+
]
9+
},
10+
{
11+
"cell_type": "code",
12+
"execution_count": null,
13+
"metadata": {
14+
"collapsed": false
15+
},
16+
"outputs": [],
17+
"source": [
18+
"import matplotlib.pyplot as plt\nimport numpy as np\n\nfrom matplotlib.collections import LineCollection\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, they will not autoscale\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 = 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()"
19+
]
20+
},
21+
{
22+
"cell_type": "markdown",
23+
"metadata": {},
24+
"source": [
25+
"In the following example, instead of passing a list of colors\n(``colors=colors``), we pass an array of values (``array=x``) that get\ncolormapped.\n\n"
26+
]
27+
},
28+
{
29+
"cell_type": "code",
30+
"execution_count": null,
31+
"metadata": {
32+
"collapsed": false
33+
},
34+
"outputs": [],
35+
"source": [
36+
"N = 50\nx = np.arange(N)\nys = [x + i for i in x] # Many sets of y to plot vs. x\nsegs = [np.column_stack([x, y]) for y in ys]\n\nfig, ax = plt.subplots()\nax.set_xlim(np.min(x), np.max(x))\nax.set_ylim(np.min(ys), np.max(ys))\n\nline_segments = LineCollection(segs, array=x,\n linewidths=(0.5, 1, 1.5, 2),\n linestyles='solid')\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()"
37+
]
38+
},
39+
{
40+
"cell_type": "markdown",
41+
"metadata": {},
42+
"source": [
43+
".. 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"
44+
]
45+
}
46+
],
47+
"metadata": {
48+
"kernelspec": {
49+
"display_name": "Python 3",
50+
"language": "python",
51+
"name": "python3"
52+
},
53+
"language_info": {
54+
"codemirror_mode": {
55+
"name": "ipython",
56+
"version": 3
57+
},
58+
"file_extension": ".py",
59+
"mimetype": "text/x-python",
60+
"name": "python",
61+
"nbconvert_exporter": "python",
62+
"pygments_lexer": "ipython3",
63+
"version": "3.12.2"
64+
}
65+
},
66+
"nbformat": 4,
67+
"nbformat_minor": 0
68+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
"""
2+
==============
3+
stairs(values)
4+
==============
5+
6+
See `~matplotlib.axes.Axes.stairs` when plotting :math:`y` between
7+
:math:`(x_i, x_{i+1})`. For plotting :math:`y` at :math:`x`, see
8+
`~matplotlib.axes.Axes.step`.
9+
10+
.. redirect-from:: /plot_types/basic/step
11+
"""
12+
import matplotlib.pyplot as plt
13+
import numpy as np
14+
15+
plt.style.use('_mpl-gallery')
16+
17+
# make data
18+
y = [4.8, 5.5, 3.5, 4.6, 6.5, 6.6, 2.6, 3.0]
19+
20+
# plot
21+
fig, ax = plt.subplots()
22+
23+
ax.stairs(y, linewidth=2.5)
24+
25+
ax.set(xlim=(0, 8), xticks=np.arange(1, 8),
26+
ylim=(0, 8), yticks=np.arange(1, 8))
27+
28+
plt.show()
Loading
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
x = np.linspace(1., 3., 10)
2+
y = x**3
3+
4+
fig, ax = plt.subplots()
5+
ax.plot(x, y, linestyle='--', color='orange', gapcolor='blue',
6+
linewidth=3, label='a striped line')
7+
ax.legend()
Loading
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
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 matplotlib.pyplot as plt
14+
import numpy as np
15+
16+
import matplotlib.cm as cm
17+
18+
# %%
19+
20+
fig = plt.figure()
21+
s = plt.scatter([1, 2, 3], [4, 5, 6])
22+
s.set_urls(['https://www.bbc.com/news', 'https://www.google.com/', None])
23+
fig.savefig('scatter.svg')
24+
25+
# %%
26+
27+
fig = plt.figure()
28+
delta = 0.025
29+
x = y = np.arange(-3.0, 3.0, delta)
30+
X, Y = np.meshgrid(x, y)
31+
Z1 = np.exp(-X**2 - Y**2)
32+
Z2 = np.exp(-(X - 1)**2 - (Y - 1)**2)
33+
Z = (Z1 - Z2) * 2
34+
35+
im = plt.imshow(Z, interpolation='bilinear', cmap=cm.gray,
36+
origin='lower', extent=(-3, 3, -3, 3))
37+
38+
im.set_url('https://www.google.com/')
39+
fig.savefig('image.svg')
Loading
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
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+
Output generated via `matplotlib.animation.Animation.to_jshtml`.
15+
"""
16+
17+
import matplotlib.pyplot as plt
18+
import numpy as np
19+
20+
np.random.seed(19680801)
21+
data = np.random.random((50, 50, 50))
22+
23+
fig, ax = plt.subplots()
24+
25+
for i, img in enumerate(data):
26+
ax.clear()
27+
ax.imshow(img)
28+
ax.set_title(f"frame {i}")
29+
# Note that using time.sleep does *not* work here!
30+
plt.pause(0.1)
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,86 @@
1+
{
2+
"cells": [
3+
{
4+
"cell_type": "markdown",
5+
"metadata": {},
6+
"source": [
7+
"\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"
8+
]
9+
},
10+
{
11+
"cell_type": "code",
12+
"execution_count": null,
13+
"metadata": {
14+
"collapsed": false
15+
},
16+
"outputs": [],
17+
"source": [
18+
"import matplotlib.pyplot as plt\n\nfrom matplotlib.patches import Rectangle\n\nfig, axs = plt.subplots(2, 5, layout='constrained', 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)"
19+
]
20+
},
21+
{
22+
"cell_type": "markdown",
23+
"metadata": {},
24+
"source": [
25+
"Hatching patterns can be repeated to increase the density.\n\n"
26+
]
27+
},
28+
{
29+
"cell_type": "code",
30+
"execution_count": null,
31+
"metadata": {
32+
"collapsed": false
33+
},
34+
"outputs": [],
35+
"source": [
36+
"fig, axs = plt.subplots(2, 5, layout='constrained', figsize=(6.4, 3.2))\n\nhatches = ['//', '\\\\\\\\', '||', '--', '++', 'xx', 'oo', 'OO', '..', '**']\n\nfor ax, h in zip(axs.flat, hatches):\n hatches_plot(ax, h)"
37+
]
38+
},
39+
{
40+
"cell_type": "markdown",
41+
"metadata": {},
42+
"source": [
43+
"Hatching patterns can be combined to create additional patterns.\n\n"
44+
]
45+
},
46+
{
47+
"cell_type": "code",
48+
"execution_count": null,
49+
"metadata": {
50+
"collapsed": false
51+
},
52+
"outputs": [],
53+
"source": [
54+
"fig, axs = plt.subplots(2, 5, layout='constrained', 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)"
55+
]
56+
},
57+
{
58+
"cell_type": "markdown",
59+
"metadata": {},
60+
"source": [
61+
".. 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"
62+
]
63+
}
64+
],
65+
"metadata": {
66+
"kernelspec": {
67+
"display_name": "Python 3",
68+
"language": "python",
69+
"name": "python3"
70+
},
71+
"language_info": {
72+
"codemirror_mode": {
73+
"name": "ipython",
74+
"version": 3
75+
},
76+
"file_extension": ".py",
77+
"mimetype": "text/x-python",
78+
"name": "python",
79+
"nbconvert_exporter": "python",
80+
"pygments_lexer": "ipython3",
81+
"version": "3.12.2"
82+
}
83+
},
84+
"nbformat": 4,
85+
"nbformat_minor": 0
86+
}

0 commit comments

Comments
 (0)