10000 Merge branch 'v2.2.2-doc' into v2.2.x · matplotlib/matplotlib@863a97d · GitHub
[go: up one dir, main page]

Skip to content

Commit 863a97d

Browse files
committed
Merge branch 'v2.2.2-doc' into v2.2.x
2 parents fe65745 + 6ee7940 commit 863a97d

File tree

13 files changed

+453
-28
lines changed

13 files changed

+453
-28
lines changed

.travis.yml

Lines changed: 11 additions & 4 deletions
6D40
Original file line numberDiff line numberDiff line change
@@ -51,10 +51,14 @@ env:
5151
- NOSE=
5252
- NUMPY=numpy
5353
- PANDAS=
54+
- PILLOW=pillow
5455
- PYPARSING=pyparsing
55-
- PYTEST='pytest!=3.3.0,>=3.2.0'
56+
# pytest-timeout master depends on pytest>=3.6. Testing with pytest 3.1 is
57+
# still supported; this is tested by the first matrix entry.
58+
- PYTEST='pytest>=3.6'
5659
- PYTEST_COV=pytest-cov
5760
- PYTEST_PEP8=
61+
- PYTEST_TIMEOUT=pytest-timeout
5862
- SPHINX=sphinx
5963
- OPENBLAS_NUM_THREADS=1
6064
- NPROC=2
@@ -77,6 +81,7 @@ matrix:
7781
- PYPARSING=pyparsing==2.0.1
7882
- PYTEST=pytest==3.1.0
7983
- PYTEST_COV=pytest-cov==2.3.1
84+
- PYTEST_TIMEOUT=pytest-timeout==1.2.1 # Newer pytest-timeouts don't support pytest <3.4.
8085
- SPHINX=sphinx==1.3
8186
- python: 3.4
8287
env: PYTHON_ARGS=-OO
@@ -87,7 +92,9 @@ matrix:
8792
- os: osx
8893
osx_image: xcode7.3
8994
language: generic # https://github.com/travis-ci/travis-ci/issues/2312
90-
env: MOCK=mock
95+
env:
96+
- MOCK=mock
97+
- PILLOW='pillow!=5.1.0'
9198
only: master
9299
cache:
93100
# As for now travis caches only "$HOME/.cache/pip"
@@ -139,7 +146,7 @@ install:
139146
$PANDAS \
140147
codecov \
141148
coverage \
142-
pillow \
149+
$PILLOW \
143150
$PYPARSING \
144151
$DATEUTIL \
145152
$SPHINX
@@ -169,7 +176,7 @@ install:
169176
pytest-faulthandler \
170177
$PYTEST_PEP8 \
171178
pytest-rerunfailures \
172-
pytest-timeout \
179+
$PYTEST_TIMEOUT \
173180
pytest-xdist
174181
175182
# Use the special local version of freetype for testing

doc/_static/mpl.css

Lines changed: 23 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -416,7 +416,7 @@ div.deprecated span.versionmodified {
416416
font-weight: bold;
417417
}
418418

419-
div.green {
419+
div.green, div.hint {
420420
color: #468847;
421421
background-color: #dff0d8;
422422
border: 1px solid #d6e9c6;
@@ -773,8 +773,8 @@ figcaption {
773773

774774

775775
/* "Summer Fellowship" message. */
776-
#summer-fellowship {
777-
background: #11557C;
776+
#plotting-contest {
777+
background: #EE9816;
778778
box-sizing: border-box;
779779
color: #fffa;
780780
font-weight: bold;
@@ -786,7 +786,7 @@ figcaption {
786786
z-index: 10000;
787787
}
788788

789-
#summer-fellowship a {
789+
#plotting-contest a {
790790
color: #fff;
791791
text-decoration:underline;
792792
}
@@ -986,14 +986,32 @@ div.sphx-glr-download a {
986986
background-image: none !important;
987987
}
988988

989-
p.sphx-glr-signature a.reference.external {
989+
p.sphx-glr-signature {
990990
display: none !important;
991991
}
992992

993993
.sphx-glr-thumbcontainer a.internal {
994994
font-weight: 400;
995995
}
996996

997+
.viewcode-link {
998+
float: right;
999+
}
1000+
1001+
.viewcode-back {
1002+
float: right;
1003+
font-family: "Helvetica Neue", Helvetica, 'Lucida Grande', 'Lucida Sans Unicode', 'Geneva', 'Verdana', sans-serif;
1004+
}
1005+
1006+
div.viewcode-block:target {
1007+
margin: -1px -13px;
1008+
padding: 0 10px;
1009+
border-top: 1px solid #ccc;
1010+
border-bottom: 1px solid #ccc;
1011+
background-color: #f4debf;
1012+
1013+
}
1014+
9971015
.sidebar-announcement {
9981016
border: 1px solid #11557C;
9991017
background: #eff9ff;

doc/_templates/layout.html

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -172,10 +172,11 @@ <h3>{{ _('Navigation') }}</h3>
172172
</a>
173173
</div>
174174
{%- endif %}
175-
<div id="summer-fellowship">
176-
Applications are open for the 2018 John Hunter Matplotlib Summer Fellowship.
177-
<a href="https://www.numfocus.org/programs/john-hunter-technology-fellowship">
178-
Apply now!
175+
<div id="plotting-contest">
176+
The 2018 <a href="https://www.eiseverywhere.com/ehome/index.php?eventid=299527&tabid=648119">
177+
SciPy John Hunter Excellence in Plotting Contest </a> is accepting
178+
<a href="https://docs.google.com/forms/d/e/1FAIpQLSdpr5RxQcoXqF768vFcUi5G3R5q8u_k_tgdNanChqerr-2YIw/viewform">
179+
submissions until June 8th!
179180
</a>
180181
</div>
181182
<div style="background-color: white; text-align: left; padding: 10px 10px 15px 15px; position: relative;">

doc/conf.py

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@
3434
'sphinx.ext.doctest',
3535
'sphinx.ext.inheritance_diagram',
3636
'sphinx.ext.intersphinx',
37+
'sphinx.ext.viewcode',
3738
'IPython.sphinxext.ipython_console_highlighting',
3839
'IPython.sphinxext.ipython_directive',
3940
'numpydoc', # Needs to be loaded *after* autodoc.
@@ -75,6 +76,8 @@ def _check_deps():
7576

7677
# Import only after checking for dependencies.
7778
from sphinx_gallery.sorting import ExplicitOrder
79+
# This is only necessary to monkey patch the signature later on.
80+
from sphinx_gallery import gen_rst
7881

7982
if six.PY2:
8083
from distutils.spawn import find_executable
@@ -140,6 +143,16 @@ def _check_deps():
140143

141144
plot_gallery = 'True'
142145

146+
# Monkey-patching gallery signature to include search keywords
147+
gen_rst.SPHX_GLR_SIG = """\n
148+
.. only:: html
149+
150+
.. rst-class:: sphx-glr-signature
151+
152+
Keywords: matplotlib code example, codex, python plot, pyplot
153+
`Gallery generated by Sphinx-Gallery
154+
<https://sphinx-gallery.readthedocs.io>`_\n"""
155+
143156
# Add any paths that contain templates here, relative to this directory.
144157
templates_path = ['_templates']
145158

doc/devel/coding_guide.rst

Lines changed: 19 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -148,12 +148,26 @@ We do a backport from master to v2.2.x assuming:
148148

149149
The ``TARGET_SHA`` is the hash of the merge commit you would like to
150150
backport. This can be read off of the github PR page (in the UI with
151-
the merge notification) or through the git CLI tools.::
151+
the merge notification) or through the git CLI tools.
152152

153-
git fetch matplotlib
154-
git checkout v2.2.x
155-
git merge --ff-only matplotlib/v2.2.x
153+
Assuming that you already have a local branch ``v2.2.x`` (if not, then
154+
``git checkout -b v2.2.x``), and that your remote pointing to
155+
``https://github.com/matplotlib/matplotlib`` is called ``upstream``::
156+
157+
git fetch upstream
158+
git checkout v2.2.x # or include -b if you don't already have this.
159+
git reset --hard upstream/v2.2.x
156160
git cherry-pick -m 1 TARGET_SHA
157161
# resolve conflicts and commit if required
158162

159-
Use your discretion to push directly to upstream or to open a PR.
163+
Files with conflicts can be listed by `git status`,
164+
and will have to be fixed by hand (search on ``>>>>>``). Once
165+
the conflict is resolved, you will have to re-add the file(s) to the branch
166+
and then continue the cherry pick::
167+
168+
git add lib/matplotlib/conflicted_file.py
169+
git add lib/matplotlib/conflicted_file2.py
170+
git cherry-pick --continue
171+
172+
Use your discretion to push directly to upstream or to open a PR; be
173+
sure to push or PR against the `v2.2.x` upstream branch, not `master`!

examples/images_contours_and_fields/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()
Lines changed: 105 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,105 @@
1+
"""
2+
=======================================
3+
Contour plot of irregularly spaced data
4+
=======================================
5+
6+
Comparison of a contour plot of irregularly spaced data interpolated
7+
on a regular grid versus a tricontour plot for an unstructured triangular grid.
8+
9+
Since :meth:`~.axes.Axes.contour` and :meth:`~.axes.Axes.contourf` expect the
10+
data to live on a regular grid, plotting a contour plot of irregularly spaced
11+
data requires different methods. The two options are:
12+
13+
* Interpolate the data to a regular grid first. This can be done with on-borad
14+
means, e.g. via `~.tri.LinearTriInterpolator` or using external functionality
15+
e.g. via `scipy.interpolate.griddata`. Then plot the
16+
interpolated data with the usual :meth:`~.axes.Axes.contour`.
17+
* Directly use :meth:`~.axes.Axes.tricontour` or
18+
:meth:`~.axes.Axes.tricontourf` which will perform a triangulation
19+
internally.
20+
21+
This example shows both methods in action.
22+
"""
23+
24+
import matplotlib.pyplot as plt
25+
import matplotlib.tri as tri
26+
import numpy as np
27+
28+
np.random.seed(19680801)
29+
npts = 200
30+
ngridx = 100
31+
ngridy = 200
32+
x = np.random.uniform(-2, 2, npts)
33+
y = np.random.uniform(-2, 2, npts)
34+
z = x * np.exp(-x**2 - y**2)
35+
36+
fig, (ax1, ax2) = plt.subplots(nrows=2)
37+
38+
# -----------------------
39+
# Interpolation on a grid
40+
# -----------------------
41+
# A contour plot of irregularly spaced data coordinates
42+
# via interpolation on a grid.
43+
44+
# Create grid values first.
45+
xi = np.linspace(-2.1, 2.1, ngridx)
46+
yi = np.linspace(-2.1, 2.1, ngridy)
47+
48+
# Perform linear interpolation of the data (x,y)
49+
# on a grid defined by (xi,yi)
50+
triang = tri.Triangulation(x, y)
51+
interpolator = tri.LinearTriInterpolator(triang, z)
52+
Xi, Yi = np.meshgrid(xi, yi)
53+
zi = interpolator(Xi, Yi)
54+
55+
# Note that scipy.interpolate provides means to interpolate data on a grid
56+
# as well. The following would be an alternative to the four lines above:
57+
#from scipy.interpolate import griddata
58+
#zi = griddata((x, y), z, (xi[None,:], yi[:,None]), method='linear')
59+
60+
61+
ax1.contour(xi, yi, zi, 14, linewidths=0.5, colors='k')
62+
cntr1 = ax1.contourf(xi, yi, zi, 14, cmap="RdBu_r")
63+
64+
fig.colorbar(cntr1, ax=ax1)
65+
ax1.plot(x, y, 'ko', ms=3)
66+
ax1.axis((-2, 2, -2, 2))
67+
ax1.set_title('grid and contour (%d points, %d grid points)' %
68+
(npts, ngridx * ngridy))
69+
70+
71+
# ----------
72+
# Tricontour
73+
# ----------
74+
# Directly supply the unordered, irregularly spaced coordinates
75+
# to tricontour.
76+
77+
ax2.tricontour(x, y, z, 14, linewidths=0.5, colors='k')
78+
cntr2 = ax2.tricontourf(x, y, z, 14, cmap="RdBu_r")
79+
80+
fig.colorbar(cntr2, ax=ax2)
81+
ax2.plot(x, y, 'ko', ms=3)
82+
ax2.axis((-2, 2, -2, 2))
83+
ax2.set_title('tricontour (%d points)' % npts)
84+
85+
plt.subplots_adjust(hspace=0.5)
86+
plt.show()
87+
88+
#############################################################################
89+
#
90+
# ------------
91+
#
92+
# References
93+
# """"""""""
94+
#
95+
# The use of the following functions and methods is shown in this example:
96+
97+
import matplotlib
98+
matplotlib.axes.Axes.contour
99+
matplotlib.pyplot.contour
100+
matplotlib.axes.Axes.contourf
101+
matplotlib.pyplot.contourf
102+
matplotlib.axes.Axes.tricontour
103+
matplotlib.pyplot.tricontour
104+
matplotlib.axes.Axes.tricontourf
105+
matplotlib.pyplot.tricontourf

examples/images_contours_and_fields/matshow.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,6 @@ def samplemat(dims):
1818

1919

2020
# Display matrix
21-
plt.matshow(samplemat((15, 35)))
21+
plt.matshow(samplemat((15, 15)))
2222

2323
plt.show()

lib/matplotlib/mlab.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3323,7 +3323,7 @@ def newfunc(val, mask, mval):
33233323
fh.close()
33243324

33253325

3326-
@cbook.deprecated('2.2')
3326+
@cbook.deprecated('2.2', alternative='scipy.interpolate.griddata')
33273327
def griddata(x, y, z, xi, yi, interp='nn'):
33283328
"""
33293329
Interpolates from a nonuniformly spaced grid to some other grid.

tutorials/intermediate/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
#

0 commit comments

Comments
 (0)
0