Skip to content

Commit e12d103

Browse files
committed
Merge remote-tracking branch 'matplotlib/v2.x'
2 parents 1ca5977 + 4fc85b0 commit e12d103

30 files changed

+53
-42
lines changed

examples/api/collections_demo.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -38,9 +38,9 @@
3838
yo = rs.randn(npts)
3939
xyo = list(zip(xo, yo))
4040

41-
# Make a list of colors cycling through the rgbcmyk series.
41+
# Make a list of colors cycling through the default series.
4242
colors = [colorConverter.to_rgba(c)
43-
for c in ('r', 'g', 'b', 'c', 'y', 'm', 'k')]
43+
for c in plt.rcParams['axes.prop_cycle'].by_key()['color']]
4444

4545
fig, axes = plt.subplots(2, 2)
4646
((ax1, ax2), (ax3, ax4)) = axes # unpack the axes

examples/api/filled_step.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -172,7 +172,7 @@ def stack_hist(ax, stacked_data, sty_cycle, bottoms=None,
172172
hist_func = partial(np.histogram, bins=edges)
173173

174174
# set up style cycles
175-
color_cycle = cycler('facecolor', 'rgbm')
175+
color_cycle = cycler(facecolor=plt.rcParams['axes.prop_cycle'][:4])
176176
label_cycle = cycler('label', ['set {n}'.format(n=n) for n in range(4)])
177177
hatch_cycle = cycler('hatch', ['/', '*', '+', '|'])
178178

examples/pie_and_polar_charts/polar_bar_demo.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515

1616
# Use custom colors and opacity
1717
for r, bar in zip(radii, bars):
18-
bar.set_facecolor(plt.cm.jet(r / 10.))
18+
bar.set_facecolor(plt.cm.viridis(r / 10.))
1919
bar.set_alpha(0.5)
2020

2121
plt.show()

examples/pylab_examples/anchored_artists.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ def __init__(self, transform, size, label, loc,
2727
sep in points.
2828
"""
2929
self.size_bar = AuxTransformBox(transform)
30-
self.size_bar.add_artist(Rectangle((0, 0), size, 0, fc="none"))
30+
self.size_bar.add_artist(Rectangle((0, 0), size, 0, fc="none", lw=1.0))
3131

3232
self.txt_label = TextArea(label, minimumdescent=False)
3333

examples/pylab_examples/axes_props.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
line.set_linewidth(3)
2020

2121
for line in gridlines:
22-
line.set_linestyle('-')
22+
line.set_linestyle('-.')
2323

2424
for label in ticklabels:
2525
label.set_color('r')

examples/pylab_examples/axhspan_demo.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
plt.plot(t, s)
88
# draw a thick red hline at y=0 that spans the xrange
9-
l = plt.axhline(linewidth=4, color='r')
9+
l = plt.axhline(linewidth=8, color='#d62728')
1010

1111
# draw a default hline at y=1 that spans the xrange
1212
l = plt.axhline(y=1)
@@ -16,15 +16,15 @@
1616

1717
# draw a thick blue vline at x=0 that spans the upper quadrant of
1818
# the yrange
19-
l = plt.axvline(x=0, ymin=0.75, linewidth=4, color='b')
19+
l = plt.axvline(x=0, ymin=0.75, linewidth=8, color='#1f77b4')
2020

2121
# draw a default hline at y=.5 that spans the middle half of
2222
# the axes
2323
l = plt.axhline(y=.5, xmin=0.25, xmax=0.75)
2424

2525
p = plt.axhspan(0.25, 0.75, facecolor='0.5', alpha=0.5)
2626

27-
p = plt.axvspan(1.25, 1.55, facecolor='g', alpha=0.5)
27+
p = plt.axvspan(1.25, 1.55, facecolor='#2ca02c', alpha=0.5)
2828

2929
plt.axis([-1, 2, -1, 2])
3030

examples/pylab_examples/bar_stacked.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
ind = np.arange(N) # the x locations for the groups
1313
width = 0.35 # the width of the bars: can also be len(x) sequence
1414

15-
p1 = plt.bar(ind, menMeans, width, yerr=menStd)
15+
p1 = plt.bar(ind, menMeans, width, color='#d62728', yerr=menStd)
1616
p2 = plt.bar(ind, womenMeans, width,
1717
bottom=menMeans, yerr=womenStd)
1818

examples/pylab_examples/cohere_demo.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
s2 = 0.01*np.sin(2*np.pi*10*t) + cnse2
2323

2424
plt.subplot(211)
25-
plt.plot(t, s1, 'b-', t, s2, 'g-')
25+
plt.plot(t, s1, t, s2)
2626
plt.xlim(0, 5)
2727
plt.xlabel('time')
2828
plt.ylabel('s1 and s2')

examples/pylab_examples/color_by_yvalue.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -13,5 +13,5 @@
1313
slower = np.ma.masked_where(s > lower, s)
1414
smiddle = np.ma.masked_where(np.logical_or(s < lower, s > upper), s)
1515

16-
plt.plot(t, slower, 'r', t, smiddle, 'b', t, supper, 'g')
16+
plt.plot(t, smiddle, t, slower, t, supper)
1717
plt.show()

examples/pylab_examples/csd_demo.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
s2 = 0.01*np.sin(2*np.pi*10*t) + cnse2
2323

2424
plt.subplot(211)
25-
plt.plot(t, s1, 'b-', t, s2, 'g-')
25+
plt.plot(t, s1, t, s2)
2626
plt.xlim(0, 5)
2727
plt.xlabel('time')
2828
plt.ylabel('s1 and s2')

examples/pylab_examples/figimage_demo.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
Z.shape = 100, 100
1414
Z[:, 50:] = 1.
1515

16-
im1 = plt.figimage(Z, xo=50, yo=0, cmap=cm.jet, origin='lower')
17-
im2 = plt.figimage(Z, xo=100, yo=100, alpha=.8, cmap=cm.jet, origin='lower')
16+
im1 = plt.figimage(Z, xo=50, yo=0, origin='lower')
17+
im2 = plt.figimage(Z, xo=100, yo=100, alpha=.8, origin='lower')
1818

1919
plt.show()

examples/pylab_examples/hist_colormapped.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
norm = colors.Normalize(fracs.min(), fracs.max())
1717

1818
for thisfrac, thispatch in zip(fracs, patches):
19-
color = cm.jet(norm(thisfrac))
19+
color = cm.viridis(norm(thisfrac))
2020
thispatch.set_facecolor(color)
2121

2222

examples/pylab_examples/image_origin.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -15,11 +15,11 @@
1515
lim = -2, 11, -2, 6
1616
plt.subplot(211, facecolor='g')
1717
plt.title('blue should be up')
18-
plt.imshow(x, origin='upper', interpolation=interp, cmap='jet')
18+
plt.imshow(x, origin='upper', interpolation=interp)
1919
#plt.axis(lim)
2020

2121
plt.subplot(212, facecolor='y')
2222
plt.title('blue should be down')
23-
plt.imshow(x, origin='lower', interpolation=interp, cmap='jet')
23+
plt.imshow(x, origin='lower', interpolation=interp)
2424
#plt.axis(lim)
2525
plt.show()

examples/pylab_examples/interp_demo.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,5 +9,5 @@
99
yi = stineman_interp(xi, x, y, yp)
1010

1111
fig, ax = plt.subplots()
12-
ax.plot(x, y, 'ro', xi, yi, '-b.')
12+
ax.plot(x, y, 'o', xi, yi, '.')
1313
plt.show()

examples/pylab_examples/layer_images.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ def func3(x, y):
3636

3737
Z2 = func3(X, Y)
3838

39-
im2 = plt.imshow(Z2, cmap=plt.cm.jet, alpha=.9, interpolation='bilinear',
39+
im2 = plt.imshow(Z2, cmap=plt.cm.viridis, alpha=.9, interpolation='bilinear',
4040
extent=extent)
4141

4242
plt.show()

examples/pylab_examples/leftventricle_bulleye.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ def bullseye_plot(ax, data, segBold=None, cmap=None, norm=None):
4646
data = np.array(data).ravel()
4747

4848
if cmap is None:
49-
cmap = plt.cm.jet
49+
cmap = plt.cm.viridis
5050

5151
if norm is None:
5252
norm = mpl.colors.Normalize(vmin=data.min(), vmax=data.max())
@@ -142,7 +142,7 @@ def bullseye_plot(ax, data, segBold=None, cmap=None, norm=None):
142142

143143
# Set the colormap and norm to correspond to the data for which
144144
# the colorbar will be used.
145-
cmap = mpl.cm.jet
145+
cmap = mpl.cm.viridis
146146
norm = mpl.colors.Normalize(vmin=1, vmax=17)
147147

148148
# ColorbarBase derives from ScalarMappable and puts a colorbar

examples/pylab_examples/legend_demo5.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ def create_artists(self, legend, orig_handle,
5252
x = np.linspace(0, 5, 100)
5353

5454
plt.figure()
55-
colors = ['red', 'orange', 'yellow', 'green', 'blue']
55+
colors = plt.rcParams['axes.prop_cycle'].by_key()['color'][:5]
5656
styles = ['solid', 'dashed', 'dashed', 'dashed', 'solid']
5757
lines = []
5858
for i, color, style in zip(range(5), colors, styles):

examples/pylab_examples/line_collection.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,8 @@
3030
# where onoffseq is an even length tuple of on and off ink in points.
3131
# If linestyle is omitted, 'solid' is used
3232
# See matplotlib.collections.LineCollection for more information
33-
colors = [colorConverter.to_rgba(i) for i in 'bgrcmyk']
33+
colors = [colorConverter.to_rgba(c)
34+
for c in plt.rcParams['axes.prop_cycle'].by_key()['color']]
3435

3536
line_segments = LineCollection(segs, linewidths=(0.5, 1, 1.5, 2),
3637
colors=colors, linestyle='solid')

examples/pylab_examples/masked_demo.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
ym1 = np.ma.masked_where(y1 > 0.5, y1)
1616
ym2 = np.ma.masked_where(y2 < -0.5, y2)
1717

18-
lines = plt.plot(x, y, 'r', x, ym1, 'g', x, ym2, 'bo')
18+
lines = plt.plot(x, y, x, ym1, x, ym2, 'o')
1919
plt.setp(lines[0], linewidth=4)
2020
plt.setp(lines[1], linewidth=2)
2121
plt.setp(lines[2], markersize=10)

examples/pylab_examples/multiline.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@
3232
plt.xticks([0.2, 0.4, 0.6, 0.8, 1.],
3333
["Jan\n2009", "Feb\n2009", "Mar\n2009", "Apr\n2009", "May\n2009"])
3434

35-
plt.axhline(0.7)
35+
plt.axhline(0.4)
3636
plt.title("test line spacing for multiline text")
3737

3838
plt.subplots_adjust(bottom=0.25, top=0.75)

examples/pylab_examples/quadmesh_demo.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -32,9 +32,9 @@
3232

3333
ax = fig.add_subplot(122)
3434
# You can control the color of the masked region:
35-
#cmap = cm.jet
36-
#cmap.set_bad('r', 1.0)
37-
#ax.pcolormesh(Qx,Qz,Zm, cmap=cmap)
35+
# cmap = cm.RdBu
36+
# cmap.set_bad('y', 1.0)
37+
# ax.pcolormesh(Qx, Qz, Zm, cmap=cmap)
3838
# Or use the default, which is transparent:
3939
col = ax.pcolormesh(Qx, Qz, Zm, shading='gouraud')
4040
ax.set_title('With masked values')

examples/pylab_examples/stem_plot.py

-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33

44
x = np.linspace(0.1, 2*np.pi, 10)
55
markerline, stemlines, baseline = plt.stem(x, np.cos(x), '-.')
6-
plt.setp(markerline, 'markerfacecolor', 'b')
76
plt.setp(baseline, 'color', 'r', 'linewidth', 2)
87

98
plt.show()

examples/pylab_examples/stock_demo.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
d1, p1, d2, p2 = get_two_stock_data()
88

99
fig, ax = plt.subplots()
10-
lines = plt.plot(d1, p1, 'bs', d2, p2, 'go')
10+
lines = plt.plot(d1, p1, 's', d2, p2, 'o')
1111
plt.xlabel('Days')
1212
plt.ylabel('Normalized price')
1313
plt.xlim(0, 3)

examples/pylab_examples/subplots_demo.py

+11-1
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,16 @@
6666
plt.setp([a.get_yticklabels() for a in axarr[:, 1]], visible=False)
6767

6868
# Four polar axes
69-
plt.subplots(2, 2, subplot_kw=dict(projection='polar'))
69+
f, axarr = plt.subplots(2, 2, subplot_kw=dict(projection='polar'))
70+
axarr[0, 0].plot(x, y)
71+
axarr[0, 0].set_title('Axis [0,0]')
72+
axarr[0, 1].scatter(x, y)
73+
axarr[0, 1].set_title('Axis [0,1]')
74+
axarr[1, 0].plot(x, y ** 2)
75+
axarr[1, 0].set_title('Axis [1,0]')
76+
axarr[1, 1].scatter(x, y ** 2)
77+
axarr[1, 1].set_title('Axis [1,1]')
78+
# Fine-tune figure; make subplots farther from each other.
79+
f.subplots_adjust(hspace=0.3)
7080

7181
plt.show()

examples/pylab_examples/vline_hline_demo.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -20,12 +20,12 @@ def f(t):
2020
vax = fig.add_subplot(121)
2121
hax = fig.add_subplot(122)
2222

23-
vax.plot(t, s + nse, 'b^')
23+
vax.plot(t, s + nse, '^')
2424
vax.vlines(t, [0], s)
2525
vax.set_xlabel('time (s)')
2626
vax.set_title('Vertical lines demo')
2727

28-
hax.plot(s + nse, t, 'b^')
28+
hax.plot(s + nse, t, '^')
2929
hax.hlines(t, [0], s, lw=2)
3030
hax.set_xlabel('time (s)')
3131
hax.set_title('Horizontal lines demo')

examples/specialty_plots/advanced_hillshading.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ def shade_other_data():
5656
z2 = np.cos(x**2 + y**2) # Data to color
5757

5858
norm = Normalize(z2.min(), z2.max())
59-
cmap = plt.cm.jet
59+
cmap = plt.cm.RdBu
6060

6161
ls = LightSource(315, 45)
6262
rgb = ls.shade_rgb(cmap(norm(z2)), z1)

examples/style_sheets/plot_dark_background.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212

1313
L = 6
1414
x = np.linspace(0, L)
15-
ncolors = len(plt.rcParams['axes.color_cycle'])
15+
ncolors = len(plt.rcParams['axes.prop_cycle'])
1616
shift = np.linspace(0, L, ncolors, endpoint=False)
1717
for s in shift:
1818
plt.plot(x, np.sin(x + s), 'o-')

examples/style_sheets/plot_ggplot.py

+5-4
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
# sinusoidal lines with colors from default color cycle
2626
L = 2*np.pi
2727
x = np.linspace(0, L)
28-
ncolors = len(plt.rcParams['axes.color_cycle'])
28+
ncolors = len(plt.rcParams['axes.prop_cycle'])
2929
shift = np.linspace(0, L, ncolors, endpoint=False)
3030
for s in shift:
3131
ax2.plot(x, np.sin(x + s), '-')
@@ -36,14 +36,15 @@
3636
y1, y2 = np.random.randint(1, 25, size=(2, 5))
3737
width = 0.25
3838
ax3.bar(x, y1, width)
39-
ax3.bar(x + width, y2, width, color=plt.rcParams['axes.color_cycle'][2])
39+
ax3.bar(x + width, y2, width,
40+
color=list(plt.rcParams['axes.prop_cycle'])[2]['color'])
4041
ax3.set_xticks(x + width)
4142
ax3.set_xticklabels(['a', 'b', 'c', 'd', 'e'])
4243

4344
# circles with colors from default color cycle
44-
for i, color in enumerate(plt.rcParams['axes.color_cycle']):
45+
for i, color in enumerate(plt.rcParams['axes.prop_cycle']):
4546
xy = np.random.normal(size=2)
46-
ax4.add_patch(plt.Circle(xy, radius=0.3, color=color))
47+
ax4.add_patch(plt.Circle(xy, radius=0.3, color=color['color']))
4748
ax4.axis('equal')
4849
ax4.margins(0)
4950

examples/style_sheets/plot_grayscale.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
def color_cycle_example(ax):
1212
L = 6
1313
x = np.linspace(0, L)
14-
ncolors = len(plt.rcParams['axes.color_cycle'])
14+
ncolors = len(plt.rcParams['axes.prop_cycle'])
1515
shift = np.linspace(0, L, ncolors, endpoint=False)
1616
for s in shift:
1717
ax.plot(x, np.sin(x + s), 'o-')

examples/user_interfaces/embedding_in_wx3.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ def init_plot_data(self):
7474
y = np.arange(100.0) * 2 * np.pi / 50.0
7575
self.x, self.y = np.meshgrid(x, y)
7676
z = np.sin(self.x) + np.cos(self.y)
77-
self.im = a.imshow(z, cmap=cm.jet) # , interpolation='nearest')
77+
self.im = a.imshow(z, cmap=cm.RdBu) # , interpolation='nearest')
7878

7979
zmax = np.amax(z) - ERR_TOL
8080
ymax_i, xmax_i = np.nonzero(z >= zmax)

0 commit comments

Comments
 (0)