Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 05330f5

Browse files
committed
rebuild 2.2.2 docs to remove header
1 parent f749666 commit 05330f5

File tree

6,460 files changed

+706052
-57796
lines changed

Some content is hidden

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

6,460 files changed

+706052
-57796
lines changed

2.2.2/Matplotlib.tex

Lines changed: 201669 additions & 0 deletions
Large diffs are not rendered by default.

2.2.2/_downloads/color_cycle.ipynb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@
105105
"cell_type": "markdown",
106106
"metadata": {},
107107
"source": [
108-
"Setting ``prop_cycler`` in the ``matplotlibrc`` file or style files\n-------------------------------------------------------------------\n\nRemember, if you want to set a custom ``prop_cycler`` in your\n``.matplotlibrc`` file or a style file (``style.mplstyle``), you can set the\n``axes.prop_cycle`` property:\n\n..code-block:: python\n\n axes.prop_cycle : cycler('color', 'bgrcmyk')\n\nCycling through multiple properties\n-----------------------------------\n\nYou can add cyclers:\n\n.. code-block:: python\n\n from cycler import cycler\n cc = (cycler(color=list('rgb')) +\n cycler(linestyle=['-', '--', '-.']))\n for d in cc:\n print(d)\n\nResults in:\n\n.. code-block:: python\n\n {'color': 'r', 'linestyle': '-'}\n {'color': 'g', 'linestyle': '--'}\n {'color': 'b', 'linestyle': '-.'}\n\n\nYou can multiply cyclers:\n\n.. code-block:: python\n\n from cycler import cycler\n cc = (cycler(color=list('rgb')) *\n cycler(linestyle=['-', '--', '-.']))\n for d in cc:\n print(d)\n\nResults in:\n\n.. code-block:: python\n\n {'color': 'r', 'linestyle': '-'}\n {'color': 'r', 'linestyle': '--'}\n {'color': 'r', 'linestyle': '-.'}\n {'color': 'g', 'linestyle': '-'}\n {'color': 'g', 'linestyle': '--'}\n {'color': 'g', 'linestyle': '-.'}\n {'color': 'b', 'linestyle': '-'}\n {'color': 'b', 'linestyle': '--'}\n {'color': 'b', 'linestyle': '-.'}\n\n"
108+
"Setting ``prop_cycler`` in the ``matplotlibrc`` file or style files\n-------------------------------------------------------------------\n\nRemember, if you want to set a custom ``prop_cycler`` in your\n``.matplotlibrc`` file or a style file (``style.mplstyle``), you can set the\n``axes.prop_cycle`` property:\n\n.. code-block:: python\n\n axes.prop_cycle : cycler('color', 'bgrcmyk')\n\nCycling through multiple properties\n-----------------------------------\n\nYou can add cyclers:\n\n.. code-block:: python\n\n from cycler import cycler\n cc = (cycler(color=list('rgb')) +\n cycler(linestyle=['-', '--', '-.']))\n for d in cc:\n print(d)\n\nResults in:\n\n.. code-block:: python\n\n {'color': 'r', 'linestyle': '-'}\n {'color': 'g', 'linestyle': '--'}\n {'color': 'b', 'linestyle': '-.'}\n\n\nYou can multiply cyclers:\n\n.. code-block:: python\n\n from cycler import cycler\n cc = (cycler(color=list('rgb')) *\n cycler(linestyle=['-', '--', '-.']))\n for d in cc:\n print(d)\n\nResults in:\n\n.. code-block:: python\n\n {'color': 'r', 'linestyle': '-'}\n {'color': 'r', 'linestyle': '--'}\n {'color': 'r', 'linestyle': '-.'}\n {'color': 'g', 'linestyle': '-'}\n {'color': 'g', 'linestyle': '--'}\n {'color': 'g', 'linestyle': '-.'}\n {'color': 'b', 'linestyle': '-'}\n {'color': 'b', 'linestyle': '--'}\n {'color': 'b', 'linestyle': '-.'}\n\n"
109109
]
110110
}
111111
],

2.2.2/_downloads/color_cycle.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@
7474
# ``.matplotlibrc`` file or a style file (``style.mplstyle``), you can set the
7575
# ``axes.prop_cycle`` property:
7676
#
77-
# ..code-block:: python
77+
# .. code-block:: python
7878
#
7979
# axes.prop_cycle : cycler('color', 'bgrcmyk')
8080
#
Lines changed: 54 additions & 0 deletions
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# Custom tick formatter for time series\n\n\nWhen plotting time series, e.g., financial time series, one often wants\nto leave out days on which there is no data, i.e. weekends. The example\nbelow shows how to use an 'index formatter' to achieve the desired 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+
"from __future__ import print_function\nimport numpy as np\nimport matplotlib.pyplot as plt\nimport matplotlib.cbook as cbook\nimport matplotlib.ticker as ticker\n\n# Load a numpy record array from yahoo csv data with fields date, open, close,\n# volume, adj_close from the mpl-data/example directory. The record array\n# stores the date as an np.datetime64 with a day unit ('D') in the date column.\nwith cbook.get_sample_data('goog.npz') as datafile:\n r = np.load(datafile)['price_data'].view(np.recarray)\nr = r[-30:] # get the last 30 days\n# Matplotlib works better with datetime.datetime than np.datetime64, but the\n# latter is more portable.\ndate = r.date.astype('O')\n\n# first we'll do it the default way, with gaps on weekends\nfig, axes = plt.subplots(ncols=2, figsize=(8, 4))\nax = axes[0]\nax.plot(date, r.adj_close, 'o-')\nax.set_title(\"Default\")\nfig.autofmt_xdate()\n\n# next we'll write a custom formatter\nN = len(r)\nind = np.arange(N) # the evenly spaced plot indices\n\n\ndef format_date(x, pos=None):\n thisind = np.clip(int(x + 0.5), 0, N - 1)\n return date[thisind].strftime('%Y-%m-%d')\n\nax = axes[1]\nax.plot(ind, r.adj_close, 'o-')\nax.xaxis.set_major_formatter(ticker.FuncFormatter(format_date))\nax.set_title(\"Custom tick formatter\")\nfig.autofmt_xdate()\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.6.5"
50+
}
51+
},
52+
"nbformat": 4,
53+
"nbformat_minor": 0
54+
}
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
"""
2+
=====================================
3+
Custom tick formatter for time series
4+
=====================================
5+
6+
When plotting time series, e.g., financial time series, one often wants
7+
to leave out days on which there is no data, i.e. weekends. The example
8+
below shows how to use an 'index formatter' to achieve the desired plot
9+
"""
10+
from __future__ import print_function
11+
import numpy as np
12+
import matplotlib.pyplot as plt
13+
import matplotlib.cbook as cbook
14+
import matplotlib.ticker as ticker
15+
16+
# Load a numpy record array from yahoo csv data with fields date, open, close,
17+
# volume, adj_close from the mpl-data/example directory. The record array
18+
# stores the date as an np.datetime64 with a day unit ('D') in the date column.
19+
with cbook.get_sample_data('goog.npz') as datafile:
20+
r = np.load(datafile)['price_data'].view(np.recarray)
21+
r = r[-30:] # get the last 30 days
22+
# Matplotlib works better with datetime.datetime than np.datetime64, but the
23+
# latter is more portable.
24+
date = r.date.astype('O')
25+
26+
# first we'll do it the default way, with gaps on weekends
27+
fig, axes = plt.subplots(ncols=2, figsize=(8, 4))
28+
ax = axes[0]
29+
ax.plot(date, r.adj_close, 'o-')
30+
ax.set_title("Default")
31+
fig.autofmt_xdate()
32+
33+
# next we'll write a custom formatter
34+
N = len(r)
35+
ind = np.arange(N) # the evenly spaced plot indices
36+
37+
38+
def format_date(x, pos=None):
39+
thisind = np.clip(int(x + 0.5), 0, N - 1)
40+
return date[thisind].strftime('%Y-%m-%d')
41+
42+
ax = axes[1]
43+
ax.plot(ind, r.adj_close, 'o-')
44+
ax.xaxis.set_major_formatter(ticker.FuncFormatter(format_date))
45+
ax.set_title("Custom tick formatter")
46+
fig.autofmt_xdate()
47+
48+
plt.show()

2.2.2/_downloads/customizing.ipynb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
"cell_type": "markdown",
1616
"metadata": {},
1717
"source": [
18-
"\nCustomizing matplotlib\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 matplotlibrc_ file (which is read at startup to\nconfigure 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\n"
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 matplotlibrc_ file (which is read at startup to\nconfigure 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\n"
1919
]
2020
},
2121
{

2.2.2/_downloads/customizing.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
"""
2-
Customizing matplotlib
3-
======================
2+
Customizing Matplotlib with style sheets and rcParams
3+
=====================================================
44
5-
Tips for customizing the properties and default styles of matplotlib.
5+
Tips for customizing the properties and default styles of Matplotlib.
66
77
Using style sheets
88
------------------
@@ -11,7 +11,7 @@
1111
the same parameters as a matplotlibrc_ file (which is read at startup to
1212
configure matplotlib).
1313
14-
There are a number of pre-defined styles provided by matplotlib. For
14+
There are a number of pre-defined styles `provided by Matplotlib`_. For
1515
example, there's a pre-defined style called "ggplot", which emulates the
1616
aesthetics of ggplot_ (a popular plotting package for R_). To use this style,
1717
just add:
@@ -186,3 +186,4 @@
186186
# .. _matplotlibrc: http://matplotlib.org/users/customizing.html
187187
# .. _ggplot: http://ggplot2.org/
188188
# .. _R: https://www.r-project.org/
189+
# .. _provided by Matplotlib: https://github.com/matplotlib/matplotlib/tree/master/lib/matplotlib/mpl-data/stylelib

2.2.2/_downloads/date_index_formatter.ipynb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
"cell_type": "markdown",
1616
"metadata": {},
1717
"source": [
18-
"\n# Custom tick formatter for time series\n\n\nWhen plotting time series, e.g., financial time series, one often wants\nto leave out days on which there is no data, i.e. weekends. The example\nbelow shows how to use an 'index formatter' to achieve the desired plot\n\n"
18+
"\n# Date Index Formatter\n\n\nWhen plotting daily data, a frequent request is to plot the data\nignoring skips, e.g., no extra spaces for weekends. This is particularly\ncommon in financial time series, when you may have data for M-F and\nnot Sat, Sun and you don't want gaps in the x axis. The approach is\nto simply use the integer index for the xdata and a custom tick\nFormatter to get the appropriate date string for a given index.\n\n"
1919
]
2020
},
2121
{
@@ -26,7 +26,7 @@
2626
},
2727
"outputs": [],
2828
"source": [
29-
"from __future__ import print_function\nimport numpy as np\nimport matplotlib.pyplot as plt\nimport matplotlib.cbook as cbook\nimport matplotlib.ticker as ticker\n\n# Load a numpy record array from yahoo csv data with fields date, open, close,\n# volume, adj_close from the mpl-data/example directory. The record array\n# stores the date as an np.datetime64 with a day unit ('D') in the date column.\nwith cbook.get_sample_data('goog.npz') as datafile:\n r = np.load(datafile)['price_data'].view(np.recarray)\nr = r[-30:] # get the last 30 days\n# Matplotlib works better with datetime.datetime than np.datetime64, but the\n# latter is more portable.\ndate = r.date.astype('O')\n\n# first we'll do it the default way, with gaps on weekends\nfig, axes = plt.subplots(ncols=2, figsize=(8, 4))\nax = axes[0]\nax.plot(date, r.adj_close, 'o-')\nax.set_title(\"Default\")\nfig.autofmt_xdate()\n\n# next we'll write a custom formatter\nN = len(r)\nind = np.arange(N) # the evenly spaced plot indices\n\n\ndef format_date(x, pos=None):\n thisind = np.clip(int(x + 0.5), 0, N - 1)\n return date[thisind].strftime('%Y-%m-%d')\n\nax = axes[1]\nax.plot(ind, r.adj_close, 'o-')\nax.xaxis.set_major_formatter(ticker.FuncFormatter(format_date))\nax.set_title(\"Custom tick formatter\")\nfig.autofmt_xdate()\n\nplt.show()"
29+
"from __future__ import print_function\n\nimport numpy as np\n\nimport matplotlib.pyplot as plt\nimport matplotlib.cbook as cbook\nfrom matplotlib.dates import bytespdate2num, num2date\nfrom matplotlib.ticker import Formatter\n\n\ndatafile = cbook.get_sample_data('msft.csv', asfileobj=False)\nprint('loading %s' % datafile)\nmsft_data = np.genfromtxt(datafile, delimiter=',', names=True,\n converters={0: bytespdate2num('%d-%b-%y')})[-40:]\n\n\nclass MyFormatter(Formatter):\n def __init__(self, dates, fmt='%Y-%m-%d'):\n self.dates = dates\n self.fmt = fmt\n\n def __call__(self, x, pos=0):\n 'Return the label for time x at position pos'\n ind = int(np.round(x))\n if ind >= len(self.dates) or ind < 0:\n return ''\n\n return num2date(self.dates[ind]).strftime(self.fmt)\n\nformatter = MyFormatter(msft_data['Date'])\n\nfig, ax = plt.subplots()\nax.xaxis.set_major_formatter(formatter)\nax.plot(np.arange(len(msft_data)), msft_data['Close'], 'o-')\nfig.autofmt_xdate()\nplt.show()"
3030
]
3131
}
3232
],
Lines changed: 37 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -1,48 +1,49 @@
11
"""
2-
=====================================
3-
Custom tick formatter for time series
4-
=====================================
5-
6-
When plotting time series, e.g., financial time series, one often wants
7-
to leave out days on which there is no data, i.e. weekends. The example
8-
below shows how to use an 'index formatter' to achieve the desired plot
2+
====================
3+
Date Index Formatter
4+
====================
5+
6+
When plotting daily data, a frequent request is to plot the data
7+
ignoring skips, e.g., no extra spaces for weekends. This is particularly
8+
common in financial time series, when you may have data for M-F and
9+
not Sat, Sun and you don't want gaps in the x axis. The approach is
10+
to simply use the integer index for the xdata and a custom tick
11+
Formatter to get the appropriate date string for a given index.
912
"""
13+
1014
from __future__ import print_function
15+
1116
import numpy as np
17+
1218
import matplotlib.pyplot as plt
1319
import matplotlib.cbook as cbook
14-
import matplotlib.ticker as ticker
15-
16-
# Load a numpy record array from yahoo csv data with fields date, open, close,
17-
# volume, adj_close from the mpl-data/example directory. The record array
18-
# stores the date as an np.datetime64 with a day unit ('D') in the date column.
19-
with cbook.get_sample_data('goog.npz') as datafile:
20-
r = np.load(datafile)['price_data'].view(np.recarray)
21-
r = r[-30:] # get the last 30 days
22-
# Matplotlib works better with datetime.datetime than np.datetime64, but the
23-
# latter is more portable.
24-
date = r.date.astype('O')
25-
26-
# first we'll do it the default way, with gaps on weekends
27-
fig, axes = plt.subplots(ncols=2, figsize=(8, 4))
28-
ax = axes[0]
29-
ax.plot(date, r.adj_close, 'o-')
30-
ax.set_title("Default")
31-
fig.autofmt_xdate()
20+
from matplotlib.dates import bytespdate2num, num2date
21+
from matplotlib.ticker import Formatter
3222

33-
# next we'll write a custom formatter
34-
N = len(r)
35-
ind = np.arange(N) # the evenly spaced plot indices
3623

24+
datafile = cbook.get_sample_data('msft.csv', asfileobj=False)
25+
print('loading %s' % datafile)
26+
msft_data = np.genfromtxt(datafile, delimiter=',', names=True,
27+
converters={0: bytespdate2num('%d-%b-%y')})[-40:]
3728

38-
def format_date(x, pos=None):
39-
thisind = np.clip(int(x + 0.5), 0, N - 1)
40-
return date[thisind].strftime('%Y-%m-%d')
4129

42-
ax = axes[1]
43-
ax.plot(ind, r.adj_close, 'o-')
44-
ax.xaxis.set_major_formatter(ticker.FuncFormatter(format_date))
45-
ax.set_title("Custom tick formatter")
46-
fig.autofmt_xdate()
30+
class MyFormatter(Formatter):
31+
def __init__(self, dates, fmt='%Y-%m-%d'):
32+
self.dates = dates
33+
self.fmt = fmt
34+
35+
def __call__(self, x, pos=0):
36+
'Return the label for time x at position pos'
37+
ind = int(np.round(x))
38+
if ind >= len(self.dates) or ind < 0:
39+
return ''
40+
41+
return num2date(self.dates[ind]).strftime(self.fmt)
4742

43+
formatter = MyFormatter(msft_data['Date'])
44+
45+
fig, ax = plt.subplots()
46+
ax.xaxis.set_major_formatter(formatter)
47+
ax.plot(np.arange(len(msft_data)), msft_data['Close'], 'o-')
48+
fig.autofmt_xdate()
4849
plt.show()

2.2.2/_downloads/gallery_jupyter.zip

4.45 KB
Binary file not shown.

2.2.2/_downloads/gallery_python.zip

3.26 KB
Binary file not shown.

2.2.2/_downloads/images.ipynb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@
8080
},
8181
"outputs": [],
8282
"source": [
83-
"lum_img = img[:, :, 0]\n\n# This is array slicing. You can read more in the `Numpy tutorial\n# <https://docs.scipy.org/doc/numpy-dev/user/quickstart.html>`_.\n\nplt.imshow(lum_img)"
83+
"lum_img = img[:, :, 0]\n\n# This is array slicing. You can read more in the `Numpy tutorial\n# <https://docs.scipy.org/doc/numpy/user/quickstart.html>`_.\n\nplt.imshow(lum_img)"
8484
]
8585
},
8686
{

2.2.2/_downloads/images.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,7 @@
136136
lum_img = img[:, :, 0]
137137

138138
# This is array slicing. You can read more in the `Numpy tutorial
139-
# <https://docs.scipy.org/doc/numpy-dev/user/quickstart.html>`_.
139+
# <https://docs.scipy.org/doc/numpy/user/quickstart.html>`_.
140140

141141
plt.imshow(lum_img)
142142

2.2.2/_downloads/interpolation_methods.ipynb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
},
2727
"outputs": [],
2828
"source": [
29-
"import matplotlib.pyplot as plt\nimport numpy as np\n\nmethods = [None, 'none', 'nearest', 'bilinear', 'bicubic', 'spline16',\n 'spline36', 'hanning', 'hamming', 'hermite', 'kaiser', 'quadric',\n 'catrom', 'gaussian', 'bessel', 'mitchell', 'sinc', 'lanczos']\n\n# Fixing random state for reproducibility\nnp.random.seed(19680801)\n\ngrid = np.random.rand(4, 4)\n\nfig, axes = plt.subplots(3, 6, figsize=(12, 6),\n subplot_kw={'xticks': [], 'yticks': []})\n\nfig.subplots_adjust(hspace=0.3, wspace=0.05)\n\nfor ax, interp_method in zip(axes.flat, methods):\n ax.imshow(grid, interpolation=interp_method, cmap='viridis')\n ax.set_title(interp_method)\n\nplt.show()"
29+
"import matplotlib.pyplot as plt\nimport numpy as np\n\nmethods = [None, 'none', 'nearest', 'bilinear', 'bicubic', 'spline16',\n 'spline36', 'hanning', 'hamming', 'hermite', 'kaiser', 'quadric',\n 'catrom', 'gaussian', 'bessel', 'mitchell', 'sinc', 'lanczos']\n\n# Fixing random state for reproducibility\nnp.random.seed(19680801)\n\ngrid = np.random.rand(4, 4)\n\nfig, axes = plt.subplots(nrows=3, ncols=6, figsize=(9, 4.5),\n subplot_kw={'xticks': [], 'yticks': []})\n\nfig.subplots_adjust(hspace=0.3, wspace=0.05)\n\nfor ax, interp_method in zip(axes.flat, methods):\n ax.imshow(grid, interpolation=interp_method, cmap='viridis')\n ax.set_title(str(interp_method))\n\nplt.tight_layout()\nplt.show()"
3030
]
3131
}
3232
],

2.2.2/_downloads/interpolation_methods.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,13 +27,14 @@
2727

2828
grid = np.random.rand(4, 4)
2929

30-
fig, axes = plt.subplots(3, 6, figsize=(12, 6),
30+
fig, axes = plt.subplots(nrows=3, ncols=6, figsize=(9, 4.5),
3131
subplot_kw={'xticks': [], 'yticks': []})
3232

3333
fig.subplots_adjust(hspace=0.3, wspace=0.05)
3434

3535
for ax, interp_method in zip(axes.flat, methods):
3636
ax.imshow(grid, interpolation=interp_method, cmap='viridis')
37-
ax.set_title(interp_method)
37+
ax.set_title(str(interp_method))
3838

39+
plt.tight_layout()
3940
plt.show()

0 commit comments

Comments
 (0)