Skip to content

Commit 901b3cb

Browse files
committed
added 3.1.3 docs
1 parent aa60876 commit 901b3cb

File tree

7,670 files changed

+984702
-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,670 files changed

+984702
-0
lines changed

3.1.3/Matplotlib.pdf

22.2 MB
Binary file not shown.
Lines changed: 108 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,108 @@
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# Multiple Figs Demo\n\n\nWorking with multiple figure windows and subplots\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\nimport numpy as np\n\nt = np.arange(0.0, 2.0, 0.01)\ns1 = np.sin(2*np.pi*t)\ns2 = np.sin(4*np.pi*t)"
30+
]
31+
},
32+
{
33+
"cell_type": "markdown",
34+
"metadata": {},
35+
"source": [
36+
"Create figure 1\n\n"
37+
]
38+
},
39+
{
40+
"cell_type": "code",
41+
"execution_count": null,
42+
"metadata": {
43+
"collapsed": false
44+
},
45+
"outputs": [],
46+
"source": [
47+
"plt.figure(1)\nplt.subplot(211)\nplt.plot(t, s1)\nplt.subplot(212)\nplt.plot(t, 2*s1)"
48+
]
49+
},
50+
{
51+
"cell_type": "markdown",
52+
"metadata": {},
53+
"source": [
54+
"Create figure 2\n\n"
55+
]
56+
},
57+
{
58+
"cell_type": "code",
59+
"execution_count": null,
60+
"metadata": {
61+
"collapsed": false
62+
},
63+
"outputs": [],
64+
"source": [
65+
"plt.figure(2)\nplt.plot(t, s2)"
66+
]
67+
},
68+
{
69+
"cell_type": "markdown",
70+
"metadata": {},
71+
"source": [
72+
"Now switch back to figure 1 and make some changes\n\n"
73+
]
74+
},
75+
{
76+
"cell_type": "code",
77+
"execution_count": null,
78+
"metadata": {
79+
"collapsed": false
80+
},
81+
"outputs": [],
82+
"source": [
83+
"plt.figure(1)\nplt.subplot(211)\nplt.plot(t, s2, 's')\nax = plt.gca()\nax.set_xticklabels([])\n\nplt.show()"
84+
]
85+
}
86+
],
87+
"metadata": {
88+
"kernelspec": {
89+
"display_name": "Python 3",
90+
"language": "python",
91+
"name": "python3"
92+
},
93+
"language_info": {
94+
"codemirror_mode": {
95+
"name": "ipython",
96+
"version": 3
97+
},
98+
"file_extension": ".py",
99+
"mimetype": "text/x-python",
100+
"name": "python",
101+
"nbconvert_exporter": "python",
102+
"pygments_lexer": "ipython3",
103+
"version": "3.8.1"
104+
}
105+
},
106+
"nbformat": 4,
107+
"nbformat_minor": 0
108+
}
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
'''
2+
============================================================================
3+
Demonstrates plotting contour (level) curves in 3D using the extend3d option
4+
============================================================================
5+
6+
This modification of the contour3d_demo example uses extend3d=True to
7+
extend the curves vertically into 'ribbons'.
8+
'''
9+
10+
from mpl_toolkits.mplot3d import axes3d
11+
import matplotlib.pyplot as plt
12+
from matplotlib import cm
13+
14+
fig = plt.figure()
15+
ax = fig.gca(projection='3d')
16+
X, Y, Z = axes3d.get_test_data(0.05)
17+
18+
cset = ax.contour(X, Y, Z, extend3d=True, cmap=cm.coolwarm)
19+
20+
ax.clabel(cset, fontsize=9, inline=1)
21+
22+
plt.show()
Binary file not shown.
Lines changed: 133 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,133 @@
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+
"\nCustomizing Matplotlib with style sheets and rcParams\n=====================================================\n\nTips for customizing the properties and default styles of Matplotlib.\n\nUsing style sheets\n------------------\n\nThe ``style`` package adds support for easy-to-switch plotting \"styles\" with\nthe same parameters as a\n`matplotlib rc <customizing-with-matplotlibrc-files>` file (which is read\nat startup to configure matplotlib).\n\nThere are a number of pre-defined styles `provided by Matplotlib`_. For\nexample, there's a pre-defined style called \"ggplot\", which emulates the\naesthetics of ggplot_ (a popular plotting package for R_). To use this style,\njust add:\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 as mpl\nplt.style.use('ggplot')\ndata = np.random.randn(50)"
30+
]
31+
},
32+
{
33+
"cell_type": "markdown",
34+
"metadata": {},
35+
"source": [
36+
"To list all available styles, use:\n\n"
37+
]
38+
},
39+
{
40+
"cell_type": "code",
41+
"execution_count": null,
42+
"metadata": {
43+
"collapsed": false
44+
},
45+
"outputs": [],
46+
"source": [
47+
"print(plt.style.available)"
48+
]
49+
},
50+
{
51+
"cell_type": "markdown",
52+
"metadata": {},
53+
"source": [
54+
"Defining your own style\n-----------------------\n\nYou can create custom styles and use them by calling ``style.use`` with the\npath or URL to the style sheet. Additionally, if you add your\n``<style-name>.mplstyle`` file to ``mpl_configdir/stylelib``, you can reuse\nyour custom style sheet with a call to ``style.use(<style-name>)``. By default\n``mpl_configdir`` should be ``~/.config/matplotlib``, but you can check where\nyours is with ``matplotlib.get_configdir()``; you may need to create this\ndirectory. You also can change the directory where matplotlib looks for\nthe stylelib/ folder by setting the MPLCONFIGDIR environment variable,\nsee `locating-matplotlib-config-dir`.\n\nNote that a custom style sheet in ``mpl_configdir/stylelib`` will\noverride a style sheet defined by matplotlib if the styles have the same name.\n\nFor example, you might want to create\n``mpl_configdir/stylelib/presentation.mplstyle`` with the following::\n\n axes.titlesize : 24\n axes.labelsize : 20\n lines.linewidth : 3\n lines.markersize : 10\n xtick.labelsize : 16\n ytick.labelsize : 16\n\nThen, when you want to adapt a plot designed for a paper to one that looks\ngood in a presentation, you can just add::\n\n >>> import matplotlib.pyplot as plt\n >>> plt.style.use('presentation')\n\n\nComposing styles\n----------------\n\nStyle sheets are designed to be composed together. So you can have a style\nsheet that customizes colors and a separate style sheet that alters element\nsizes for presentations. These styles can easily be combined by passing\na list of styles::\n\n >>> import matplotlib.pyplot as plt\n >>> plt.style.use(['dark_background', 'presentation'])\n\nNote that styles further to the right will overwrite values that are already\ndefined by styles on the left.\n\n\nTemporary styling\n-----------------\n\nIf you only want to use a style for a specific block of code but don't want\nto change the global styling, the style package provides a context manager\nfor limiting your changes to a specific scope. To isolate your styling\nchanges, you can write something like the following:\n\n"
55+
]
56+
},
57+
{
58+
"cell_type": "code",
59+
"execution_count": null,
60+
"metadata": {
61+
"collapsed": false
62+
},
63+
"outputs": [],
64+
"source": [
65+
"with plt.style.context('dark_background'):\n plt.plot(np.sin(np.linspace(0, 2 * np.pi)), 'r-o')\nplt.show()"
66+
]
67+
},
68+
{
69+
"cell_type": "markdown",
70+
"metadata": {},
71+
"source": [
72+
"\nmatplotlib rcParams\n===================\n\n\nDynamic rc settings\n-------------------\n\nYou can also dynamically change the default rc settings in a python script or\ninteractively from the python shell. All of the rc settings are stored in a\ndictionary-like variable called :data:`matplotlib.rcParams`, which is global to\nthe matplotlib package. rcParams can be modified directly, for example:\n\n"
73+
]
74+
},
75+
{
76+
"cell_type": "code",
77+
"execution_count": null,
78+
"metadata": {
79+
"collapsed": false
80+
},
81+
"outputs": [],
82+
"source": [
83+
"mpl.rcParams['lines.linewidth'] = 2\nmpl.rcParams['lines.color'] = 'r'\nplt.plot(data)"
84+
]
85+
},
86+
{
87+
"cell_type": "markdown",
88+
"metadata": {},
89+
"source": [
90+
"Matplotlib also provides a couple of convenience functions for modifying rc\nsettings. The :func:`matplotlib.rc` command can be used to modify multiple\nsettings in a single group at once, using keyword arguments:\n\n"
91+
]
92+
},
93+
{
94+
"cell_type": "code",
95+
"execution_count": null,
96+
"metadata": {
97+
"collapsed": false
98+
},
99+
"outputs": [],
100+
"source": [
101+
"mpl.rc('lines', linewidth=4, color='g')\nplt.plot(data)"
102+
]
103+
},
104+
{
105+
"cell_type": "markdown",
106+
"metadata": {},
107+
"source": [
108+
"The :func:`matplotlib.rcdefaults` command will restore the standard matplotlib\ndefault settings.\n\nThere is some degree of validation when setting the values of rcParams, see\n:mod:`matplotlib.rcsetup` for details.\n\n\nThe :file:`matplotlibrc` file\n-----------------------------\n\nmatplotlib uses :file:`matplotlibrc` configuration files to customize all kinds\nof properties, which we call `rc settings` or `rc parameters`. You can control\nthe defaults of almost every property in matplotlib: figure size and dpi, line\nwidth, color and style, axes, axis and grid properties, text and font\nproperties and so on. matplotlib looks for :file:`matplotlibrc` in four\nlocations, in the following order:\n\n1. :file:`matplotlibrc` in the current working directory, usually used for\n specific customizations that you do not want to apply elsewhere.\n\n2. :file:`$MATPLOTLIBRC` if it is a file, else :file:`$MATPLOTLIBRC/matplotlibrc`.\n\n3. It next looks in a user-specific place, depending on your platform:\n\n - On Linux and FreeBSD, it looks in :file:`.config/matplotlib/matplotlibrc`\n (or `$XDG_CONFIG_HOME/matplotlib/matplotlibrc`) if you've customized\n your environment.\n\n - On other platforms, it looks in :file:`.matplotlib/matplotlibrc`.\n\n See `locating-matplotlib-config-dir`.\n\n4. :file:`{INSTALL}/matplotlib/mpl-data/matplotlibrc`, where\n :file:`{INSTALL}` is something like\n :file:`/usr/lib/python3.7/site-packages` on Linux, and maybe\n :file:`C:\\\\Python37\\\\Lib\\\\site-packages` on Windows. Every time you\n install matplotlib, this file will be overwritten, so if you want\n your customizations to be saved, please move this file to your\n user-specific matplotlib directory.\n\nOnce a :file:`matplotlibrc` file has been found, it will *not* search any of\nthe other paths.\n\nTo display where the currently active :file:`matplotlibrc` file was\nloaded from, one can do the following::\n\n >>> import matplotlib\n >>> matplotlib.matplotlib_fname()\n '/home/foo/.config/matplotlib/matplotlibrc'\n\nSee below for a sample `matplotlibrc file<matplotlibrc-sample>`.\n\n\nA sample matplotlibrc file\n~~~~~~~~~~~~~~~~~~~~~~~~~~\n\n.. literalinclude:: ../../../matplotlibrc.template\n\n\n\n"
109+
]
110+
}
111+
],
112+
"metadata": {
113+
"kernelspec": {
114+
"display_name": "Python 3",
115+
"language": "python",
116+
"name": "python3"
117+
},
118+
"language_info": {
119+
"codemirror_mode": {
120+
"name": "ipython",
121+
"version": 3
122+
},
123+
"file_extension": ".py",
124+
"mimetype": "text/x-python",
125+
"name": "python",
126+
"nbconvert_exporter": "python",
127+
"pygments_lexer": "ipython3",
128+
"version": "3.8.1"
129+
}
130+
},
131+
"nbformat": 4,
132+
"nbformat_minor": 0
133+
}
Lines changed: 98 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,98 @@
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# Geographic Projections\n\n\nThis shows 4 possible projections using subplot. Matplotlib also\nsupports `Basemaps Toolkit <https://matplotlib.org/basemap>`_ and\n`Cartopy <http://scitools.org.uk/cartopy>`_ for geographic projections.\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"
30+
]
31+
},
32+
{
33+
"cell_type": "code",
34+
"execution_count": null,
35+
"metadata": {
36+
"collapsed": false
37+
},
38+
"outputs": [],
39+
"source": [
40+
"plt.figure()\nplt.subplot(111, projection=\"aitoff\")\nplt.title(\"Aitoff\")\nplt.grid(True)"
41+
]
42+
},
43+
{
44+
"cell_type": "code",
45+
"execution_count": null,
46+
"metadata": {
47+
"collapsed": false
48+
},
49+
"outputs": [],
50+
"source": [
51+
"plt.figure()\nplt.subplot(111, projection=\"hammer\")\nplt.title(\"Hammer\")\nplt.grid(True)"
52+
]
53+
},
54+
{
55+
"cell_type": "code",
56+
"execution_count": null,
57+
"metadata": {
58+
"collapsed": false
59+
},
60+
"outputs": [],
61+
"source": [
62+
"plt.figure()\nplt.subplot(111, projection=\"lambert\")\nplt.title(\"Lambert\")\nplt.grid(True)"
63+
]
64+
},
65+
{
66+
"cell_type": "code",
67+
"execution_count": null,
68+
"metadata": {
69+
"collapsed": false
70+
},
71+
"outputs": [],
72+
"source": [
73+
"plt.figure()\nplt.subplot(111, projection=\"mollweide\")\nplt.title(\"Mollweide\")\nplt.grid(True)\n\nplt.show()"
74+
]
75+
}
76+
],
77+
"metadata": {
78+
"kernelspec": {
79+
"display_name": "Python 3",
80+
"language": "python",
81+
"name": "python3"
82+
},
83+
"language_info": {
84+
"codemirror_mode": {
85+
"name": "ipython",
86+
"version": 3
87+
},
88+
"file_extension": ".py",
89+
"mimetype": "text/x-python",
90+
"name": "python",
91+
"nbconvert_exporter": "python",
92+
"pygments_lexer": "ipython3",
93+
"version": "3.8.1"
94+
}
95+
},
96+
"nbformat": 4,
97+
"nbformat_minor": 0
98+
}
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
"""
2+
===============
3+
Subplots Adjust
4+
===============
5+
6+
Adjusting the spacing of margins and subplots using
7+
:func:`~matplotlib.pyplot.subplots_adjust`.
8+
"""
9+
import matplotlib.pyplot as plt
10+
import numpy as np
11+
12+
# Fixing random state for reproducibility
13+
np.random.seed(19680801)
14+
15+
16+
plt.subplot(211)
17+
plt.imshow(np.random.random((100, 100)), cmap=plt.cm.BuPu_r)
18+
plt.subplot(212)
19+
plt.imshow(np.random.random((100, 100)), cmap=plt.cm.BuPu_r)
20+
21+
plt.subplots_adjust(bottom=0.1, right=0.8, top=0.9)
22+
cax = plt.axes([0.85, 0.1, 0.075, 0.8])
23+
plt.colorbar(cax=cax)
24+
plt.show()

0 commit comments

Comments
 (0)