Skip to content

Commit a72574d

Browse files
committed
Merge remote-tracking branch 'matplotlib/v2.x'
2 parents 25ce666 + 74ead7c commit a72574d

File tree

10 files changed

+52
-48
lines changed

10 files changed

+52
-48
lines changed

examples/api/collections_demo.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,8 @@
4141
for c in plt.rcParams['axes.prop_cycle'].by_key()['color']]
4242

4343
fig, axes = plt.subplots(2, 2)
44+
fig.subplots_adjust(top=0.92, left=0.07, right=0.97,
45+
hspace=0.3, wspace=0.3)
4446
((ax1, ax2), (ax3, ax4)) = axes # unpack the axes
4547

4648

examples/images_contours_and_fields/interpolation_none_vs_nearest.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,9 @@
5454
# example, the 'Nearest_vs_none-pdf.pdf' has been pre-converted into
5555
#'Nearest_vs_none-pdf.png' at 80 dpi. We simply need to load and
5656
# display it.
57+
# The conversion is done with:
58+
# gs -dNOPAUSE -dBATCH -dDOINTERPOLATE -sDEVICE=pngalpha \
59+
# -sOutputFile=None_vs_nearest-pdf.png -r80 None_vs_nearest-pdf.pdf
5760
pdf_im_path = cbook.get_sample_data('None_vs_nearest-pdf.png')
5861
pdf_im = plt.imread(pdf_im_path)
5962
fig2 = plt.figure(figsize=[8.0, 7.5])

examples/pylab_examples/break.py

Lines changed: 0 additions & 6 deletions
This file was deleted.

examples/pylab_examples/hexbin_demo.py

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -17,19 +17,20 @@
1717
ymin = y.min()
1818
ymax = y.max()
1919

20-
plt.subplots_adjust(hspace=0.5)
21-
plt.subplot(121)
22-
plt.hexbin(x, y, cmap=plt.cm.YlOrRd_r)
23-
plt.axis([xmin, xmax, ymin, ymax])
24-
plt.title("Hexagon binning")
25-
cb = plt.colorbar()
20+
fig, axs = plt.subplots(ncols=2, sharey=True, figsize=(7, 4))
21+
fig.subplots_adjust(hspace=0.5, left=0.07, right=0.93)
22+
ax = axs[0]
23+
hb = ax.hexbin(x, y, gridsize=50, cmap='inferno')
24+
ax.axis([xmin, xmax, ymin, ymax])
25+
ax.set_title("Hexagon binning")
26+
cb = fig.colorbar(hb, ax=ax)
2627
cb.set_label('counts')
2728

28-
plt.subplot(122)
29-
plt.hexbin(x, y, bins='log', cmap=plt.cm.YlOrRd_r)
30-
plt.axis([xmin, xmax, ymin, ymax])
31-
plt.title("With a log color scale")
32-
cb = plt.colorbar()
29+
ax = axs[1]
30+
hb = ax.hexbin(x, y, gridsize=50, bins='log', cmap='inferno')
31+
ax.axis([xmin, xmax, ymin, ymax])
32+
ax.set_title("With a log color scale")
33+
cb = fig.colorbar(hb, ax=ax)
3334
cb.set_label('log10(N)')
3435

3536
plt.show()
Lines changed: 17 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,30 @@
11
'''
2-
This illustrates the NonUniformImage class, which still needs
3-
an axes method interface; either a separate interface, or a
4-
generalization of imshow.
2+
This illustrates the NonUniformImage class. It is not
3+
available via an Axes method but it is easily added to an
4+
Axes instance as shown here.
55
'''
66

7-
from matplotlib.pyplot import figure, show
87
import numpy as np
8+
import matplotlib.pyplot as plt
99
from matplotlib.image import NonUniformImage
1010
from matplotlib import cm
1111

1212
interp = 'nearest'
1313

14+
# Linear x array for cell centers:
1415
x = np.linspace(-4, 4, 9)
16+
17+
# Highly nonlinear x array:
1518
x2 = x**3
19+
1620
y = np.linspace(-4, 4, 9)
17-
#print('Size %d points' % (len(x) * len(y)))
21+
1822
z = np.sqrt(x[np.newaxis, :]**2 + y[:, np.newaxis]**2)
1923

20-
fig = figure()
21-
fig.suptitle('NonUniformImage class')
22-
ax = fig.add_subplot(221)
24+
fig, axs = plt.subplots(nrows=2, ncols=2)
25+
fig.subplots_adjust(bottom=0.07, hspace=0.3)
26+
fig.suptitle('NonUniformImage class', fontsize='large')
27+
ax = axs[0, 0]
2328
im = NonUniformImage(ax, interpolation=interp, extent=(-4, 4, -4, 4),
2429
cmap=cm.Purples)
2530
im.set_data(x, y, z)
@@ -28,7 +33,7 @@
2833
ax.set_ylim(-4, 4)
2934
ax.set_title(interp)
3035

31-
ax = fig.add_subplot(222)
36+
ax = axs[0, 1]
3237
im = NonUniformImage(ax, interpolation=interp, extent=(-64, 64, -4, 4),
3338
cmap=cm.Purples)
3439
im.set_data(x2, y, z)
@@ -39,7 +44,7 @@
3944

4045
interp = 'bilinear'
4146

42-
ax = fig.add_subplot(223)
47+
ax = axs[1, 0]
4348
im = NonUniformImage(ax, interpolation=interp, extent=(-4, 4, -4, 4),
4449
cmap=cm.Purples)
4550
im.set_data(x, y, z)
@@ -48,7 +53,7 @@
4853
ax.set_ylim(-4, 4)
4954
ax.set_title(interp)
5055

51-
ax = fig.add_subplot(224)
56+
ax = axs[1, 1]
5257
im = NonUniformImage(ax, interpolation=interp, extent=(-64, 64, -4, 4),
5358
cmap=cm.Purples)
5459
im.set_data(x2, y, z)
@@ -57,4 +62,4 @@
5762
ax.set_ylim(-4, 4)
5863
ax.set_title(interp)
5964

60-
show()
65+
plt.show()

examples/pylab_examples/image_origin.py

Lines changed: 7 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -7,19 +7,14 @@
77
import matplotlib.pyplot as plt
88
import numpy as np
99

10-
x = np.arange(100.0)
11-
x.shape = (10, 10)
10+
x = np.arange(120)
11+
x.shape = (10, 12)
1212

1313
interp = 'bilinear'
14-
#interp = 'nearest'
15-
lim = -2, 11, -2, 6
16-
plt.subplot(211, facecolor='g')
17-
plt.title('blue should be up')
18-
plt.imshow(x, origin='upper', interpolation=interp)
19-
#plt.axis(lim)
14+
fig, axs = plt.subplots(nrows=2, sharex=True, figsize=(3, 5))
15+
axs[0].set_title('blue should be up')
16+
axs[0].imshow(x, origin='upper', interpolation=interp)
2017

21-
plt.subplot(212, facecolor='y')
22-
plt.title('blue should be down')
23-
plt.imshow(x, origin='lower', interpolation=interp)
24-
#plt.axis(lim)
18+
axs[1].set_title('blue should be down')
19+
axs[1].imshow(x, origin='lower', interpolation=interp)
2520
plt.show()

examples/scales/scales.py

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,15 +3,18 @@
33
"""
44
import numpy as np
55
import matplotlib.pyplot as plt
6+
from matplotlib.ticker import NullFormatter
67

8+
np.random.seed(1)
79
# make up some data in the interval ]0, 1[
810
y = np.random.normal(loc=0.5, scale=0.4, size=1000)
911
y = y[(y > 0) & (y < 1)]
1012
y.sort()
1113
x = np.arange(len(y))
1214

1315
# plot with various axes scales
14-
fig, axs = plt.subplots(2, 2)
16+
fig, axs = plt.subplots(2, 2, sharex=True)
17+
fig.subplots_adjust(left=0.08, right=0.98, wspace=0.3)
1518

1619
# linear
1720
ax = axs[0, 0]
@@ -30,18 +33,19 @@
3033

3134

3235
# symmetric log
33-
ax = axs[1, 0]
36+
ax = axs[1, 1]
3437
ax.plot(x, y - y.mean())
35-
ax.set_yscale('symlog', linthreshy=0.05)
38+
ax.set_yscale('symlog', linthreshy=0.02)
3639
ax.set_title('symlog')
3740
ax.grid(True)
3841

3942
# logit
40-
ax = axs[1, 1]
43+
ax = axs[1, 0]
4144
ax.plot(x, y)
4245
ax.set_yscale('logit')
4346
ax.set_title('logit')
4447
ax.grid(True)
48+
ax.yaxis.set_minor_formatter(NullFormatter())
4549

4650

4751
plt.show()

examples/specialty_plots/hinton_demo.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ def hinton(matrix, max_weight=None, ax=None):
1717
ax = ax if ax is not None else plt.gca()
1818

1919
if not max_weight:
20-
max_weight = 2**np.ceil(np.log(np.abs(matrix).max())/np.log(2))
20+
max_weight = 2 ** np.ceil(np.log(np.abs(matrix).max()) / np.log(2))
2121

2222
ax.patch.set_facecolor('gray')
2323
ax.set_aspect('equal', 'box')
@@ -26,7 +26,7 @@ def hinton(matrix, max_weight=None, ax=None):
2626

2727
for (x, y), w in np.ndenumerate(matrix):
2828
color = 'white' if w > 0 else 'black'
29-
size = np.sqrt(np.abs(w))
29+
size = np.sqrt(np.abs(w) / max_weight)
3030
rect = plt.Rectangle([x - size / 2, y - size / 2], size, size,
3131
facecolor=color, edgecolor=color)
3232
ax.add_patch(rect)
-23.8 KB
Loading

tests.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ def run(extra_args):
5050
if '--no-network' in sys.argv:
5151
from matplotlib.testing import disable_internet
5252
disable_internet.turn_off_internet()
53-
extra_args.extend(['--eval-attr="not network"'])
53+
extra_args.extend(['-a', '!network'])
5454
sys.argv.remove('--no-network')
5555

5656
run(extra_args)

0 commit comments

Comments
 (0)