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

Skip to content

Commit c0712ca

Browse files
committed
Merge branch 'master' of https://github.com/matplotlib/matplotlib into issue_10267
2 parents f30e583 + 482bde0 commit c0712ca

52 files changed

Lines changed: 487 additions & 436 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
Deprecation of backend_tkagg.AxisMenu
2+
`````````````````````````````````````
3+
The above-mentioned class is deprecated, as it has become unused since the
4+
removal of "classic" toolbars.

doc/conf.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@
3535
'sphinx.ext.inheritance_diagram', 'sphinx.ext.intersphinx',
3636
'sphinx_gallery.gen_gallery',
3737
'matplotlib.sphinxext.plot_directive',
38-
'sphinxext.github',
38+
'sphinxext.github', 'sphinxext.custom_roles',
3939
'numpydoc']
4040

4141
exclude_patterns = ['api/api_changes/*', 'users/whats_new/*']

doc/devel/MEP/MEP23.rst

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -37,10 +37,9 @@ Sometimes when there are too many figures open at the same time, it is
3737
desirable to be able to group these under the same window
3838
[see](https://github.com/matplotlib/matplotlib/issues/2194).
3939

40-
The proposed solution modifies `FigureManagerBase` to contain and
41-
manage more than one `canvas`. The settings parameter
42-
`rcParams['backend.multifigure']` control when the **MultiFigure**
43-
behaviour is desired.
40+
The proposed solution modifies `FigureManagerBase` to contain and manage more
41+
than one `canvas`. The settings parameter :rc:`backend.multifigure` control
42+
when the **MultiFigure** behaviour is desired.
4443

4544
**Note**
4645

doc/devel/documenting_mpl.rst

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -410,14 +410,15 @@ to keep in mind:
410410
-------
411411
lines : `~matplotlib.collections.LineCollection`
412412
413+
* rcParams can be referenced with the custom ``:rc:`` role:
414+
:literal:`:rc:\`foo\`` yields ``rcParams["foo"]``.
413415

414416
Deprecated formatting conventions
415417
---------------------------------
416418
* Formerly, we have used square brackets for explicit parameter lists
417419
``['solid' | 'dashed' | 'dotted']``. With numpydoc we have switched to their
418420
standard using curly braces ``{'solid', 'dashed', 'dotted'}``.
419421

420-
421422
Linking to other code
422423
---------------------
423424
To link to other methods, classes, or modules in Matplotlib you can encase

doc/sphinxext/custom_roles.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
from docutils import nodes
2+
3+
4+
def rcparam_role(name, rawtext, text, lineno, inliner, options={}, content=[]):
5+
rendered = nodes.Text('rcParams["{}"]'.format(text))
6+
return [nodes.literal(rawtext, rendered)], []
7+
8+
9+
def setup(app):
10+
app.add_role("rc", rcparam_role)
11+
return {"parallel_read_safe": True, "parallel_write_safe": True}

examples/api/mathtext_asarray.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
r'some other string', color='red', fontsize=20, dpi=200)
2323

2424
fig = plt.figure()
25-
fig.figimage(rgba1.astype(float)/255., 100, 100)
26-
fig.figimage(rgba2.astype(float)/255., 100, 300)
25+
fig.figimage(rgba1, 100, 100)
26+
fig.figimage(rgba2, 100, 300)
2727

2828
plt.show()

examples/color/color_cycle_default.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
colors = prop_cycle.by_key()['color']
1414

1515
lwbase = plt.rcParams['lines.linewidth']
16-
thin = float('%.1f' % (lwbase / 2))
16+
thin = lwbase / 2
1717
thick = lwbase * 3
1818

1919
fig, axs = plt.subplots(nrows=2, ncols=2, sharex=True, sharey=True)
@@ -29,7 +29,7 @@
2929

3030
axs[1, icol].set_facecolor('k')
3131
axs[1, icol].xaxis.set_ticks(np.arange(0, 10, 2))
32-
axs[0, icol].set_title('line widths (pts): %.1f, %.1f' % (lwx, lwy),
32+
axs[0, icol].set_title('line widths (pts): %g, %g' % (lwx, lwy),
3333
fontsize='medium')
3434

3535
for irow in range(2):

examples/images_contours_and_fields/quadmesh_demo.py

Lines changed: 20 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -9,37 +9,38 @@
99
This demo illustrates a bug in quadmesh with masked data.
1010
"""
1111

12+
import copy
13+
14+
from matplotlib import cm, colors, pyplot as plt
1215
import numpy as np
13-
from matplotlib.pyplot import figure, show, savefig
14-
from matplotlib import cm, colors
15-
from numpy import ma
1616

1717
n = 12
1818
x = np.linspace(-1.5, 1.5, n)
1919
y = np.linspace(-1.5, 1.5, n * 2)
2020
X, Y = np.meshgrid(x, y)
2121
Qx = np.cos(Y) - np.cos(X)
2222
Qz = np.sin(Y) + np.sin(X)
23-
Qx = (Qx + 1.1)
2423
Z = np.sqrt(X**2 + Y**2) / 5
2524
Z = (Z - Z.min()) / (Z.max() - Z.min())
2625

27-
# The color array can include masked values:
28-
Zm = ma.masked_where(np.abs(Qz) < 0.5 * np.max(Qz), Z)
26+
# The color array can include masked values.
27+
Zm = np.ma.masked_where(np.abs(Qz) < 0.5 * np.max(Qz), Z)
28+
29+
fig, axs = plt.subplots(1, 3)
30+
axs[0].pcolormesh(Qx, Qz, Z, shading='gouraud')
31+
axs[0].set_title('Without masked values')
2932

30-
fig = figure()
31-
ax = fig.add_subplot(121)
32-
ax.pcolormesh(Qx, Qz, Z, shading='gouraud')
33-
ax.set_title('Without masked values')
33+
# You can control the color of the masked region. We copy the default colormap
34+
# before modifying it.
35+
cmap = copy.copy(cm.get_cmap(plt.rcParams['image.cmap']))
36+
cmap.set_bad('y', 1.0)
37+
axs[1].pcolormesh(Qx, Qz, Zm, shading='gouraud', cmap=cmap)
38+
axs[1].set_title('With masked values')
3439

35-
ax = fig.add_subplot(122)
36-
# You can control the color of the masked region:
37-
# cmap = cm.RdBu
38-
# cmap.set_bad('y', 1.0)
39-
# ax.pcolormesh(Qx, Qz, Zm, cmap=cmap)
40-
# Or use the default, which is transparent:
41-
col = ax.pcolormesh(Qx, Qz, Zm, shading='gouraud')
42-
ax.set_title('With masked values')
40+
# Or use the default, which is transparent.
41+
axs[2].pcolormesh(Qx, Qz, Zm, shading='gouraud')
42+
axs[2].set_title('With masked values')
4343

44+
fig.tight_layout()
4445

45-
show()
46+
plt.show()

examples/lines_bars_and_markers/stackplot_demo.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ def bump(a):
4343
y = 2 * np.random.random() - .5
4444
z = 10 / (.1 + np.random.random())
4545
for i in range(m):
46-
w = (i / float(m) - y) * z
46+
w = (i / m - y) * z
4747
a[i] += x * np.exp(-w * w)
4848
a = np.zeros((m, n))
4949
for i in range(n):

examples/statistics/hist.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@
5252
N, bins, patches = axs[0].hist(x, bins=n_bins)
5353

5454
# We'll color code by height, but you could use any scalar
55-
fracs = N.astype(float) / N.max()
55+
fracs = N / N.max()
5656

5757
# we need to normalize the data to 0..1 for the full range of the colormap
5858
norm = colors.Normalize(fracs.min(), fracs.max())

0 commit comments

Comments
 (0)