diff --git a/examples/api/collections_demo.py b/examples/api/collections_demo.py index 90873f886d9b..beab1edb2981 100644 --- a/examples/api/collections_demo.py +++ b/examples/api/collections_demo.py @@ -38,9 +38,9 @@ yo = rs.randn(npts) xyo = list(zip(xo, yo)) -# Make a list of colors cycling through the rgbcmyk series. +# Make a list of colors cycling through the default series. colors = [colorConverter.to_rgba(c) - for c in ('r', 'g', 'b', 'c', 'y', 'm', 'k')] + for c in plt.rcParams['axes.prop_cycle'].by_key()['color']] fig, axes = plt.subplots(2, 2) ((ax1, ax2), (ax3, ax4)) = axes # unpack the axes diff --git a/examples/api/filled_step.py b/examples/api/filled_step.py index 98dbd3282c08..7778512bddf5 100644 --- a/examples/api/filled_step.py +++ b/examples/api/filled_step.py @@ -172,7 +172,7 @@ def stack_hist(ax, stacked_data, sty_cycle, bottoms=None, hist_func = partial(np.histogram, bins=edges) # set up style cycles -color_cycle = cycler('facecolor', 'rgbm') +color_cycle = cycler(facecolor=plt.rcParams['axes.prop_cycle'][:4]) label_cycle = cycler('label', ['set {n}'.format(n=n) for n in range(4)]) hatch_cycle = cycler('hatch', ['/', '*', '+', '|']) diff --git a/examples/pie_and_polar_charts/polar_bar_demo.py b/examples/pie_and_polar_charts/polar_bar_demo.py index 7cdde5f9cb35..32e3831b2bad 100644 --- a/examples/pie_and_polar_charts/polar_bar_demo.py +++ b/examples/pie_and_polar_charts/polar_bar_demo.py @@ -15,7 +15,7 @@ # Use custom colors and opacity for r, bar in zip(radii, bars): - bar.set_facecolor(plt.cm.jet(r / 10.)) + bar.set_facecolor(plt.cm.viridis(r / 10.)) bar.set_alpha(0.5) plt.show() diff --git a/examples/pylab_examples/anchored_artists.py b/examples/pylab_examples/anchored_artists.py index af4585f819fe..08104ffc383a 100644 --- a/examples/pylab_examples/anchored_artists.py +++ b/examples/pylab_examples/anchored_artists.py @@ -27,7 +27,7 @@ def __init__(self, transform, size, label, loc, sep in points. """ self.size_bar = AuxTransformBox(transform) - self.size_bar.add_artist(Rectangle((0, 0), size, 0, fc="none")) + self.size_bar.add_artist(Rectangle((0, 0), size, 0, fc="none", lw=1.0)) self.txt_label = TextArea(label, minimumdescent=False) diff --git a/examples/pylab_examples/axes_props.py b/examples/pylab_examples/axes_props.py index dff7c762d295..bc6de460a500 100644 --- a/examples/pylab_examples/axes_props.py +++ b/examples/pylab_examples/axes_props.py @@ -19,7 +19,7 @@ line.set_linewidth(3) for line in gridlines: - line.set_linestyle('-') + line.set_linestyle('-.') for label in ticklabels: label.set_color('r') diff --git a/examples/pylab_examples/axhspan_demo.py b/examples/pylab_examples/axhspan_demo.py index c7c05a5fa39f..13a91188166f 100644 --- a/examples/pylab_examples/axhspan_demo.py +++ b/examples/pylab_examples/axhspan_demo.py @@ -6,7 +6,7 @@ plt.plot(t, s) # draw a thick red hline at y=0 that spans the xrange -l = plt.axhline(linewidth=4, color='r') +l = plt.axhline(linewidth=8, color='#d62728') # draw a default hline at y=1 that spans the xrange l = plt.axhline(y=1) @@ -16,7 +16,7 @@ # draw a thick blue vline at x=0 that spans the upper quadrant of # the yrange -l = plt.axvline(x=0, ymin=0.75, linewidth=4, color='b') +l = plt.axvline(x=0, ymin=0.75, linewidth=8, color='#1f77b4') # draw a default hline at y=.5 that spans the middle half of # the axes @@ -24,7 +24,7 @@ p = plt.axhspan(0.25, 0.75, facecolor='0.5', alpha=0.5) -p = plt.axvspan(1.25, 1.55, facecolor='g', alpha=0.5) +p = plt.axvspan(1.25, 1.55, facecolor='#2ca02c', alpha=0.5) plt.axis([-1, 2, -1, 2]) diff --git a/examples/pylab_examples/bar_stacked.py b/examples/pylab_examples/bar_stacked.py index 5ce47fb8daba..daa84345fea4 100755 --- a/examples/pylab_examples/bar_stacked.py +++ b/examples/pylab_examples/bar_stacked.py @@ -12,7 +12,7 @@ ind = np.arange(N) # the x locations for the groups width = 0.35 # the width of the bars: can also be len(x) sequence -p1 = plt.bar(ind, menMeans, width, yerr=menStd) +p1 = plt.bar(ind, menMeans, width, color='#d62728', yerr=menStd) p2 = plt.bar(ind, womenMeans, width, bottom=menMeans, yerr=womenStd) diff --git a/examples/pylab_examples/cohere_demo.py b/examples/pylab_examples/cohere_demo.py index 564daab75ddd..b7a39a18ceba 100644 --- a/examples/pylab_examples/cohere_demo.py +++ b/examples/pylab_examples/cohere_demo.py @@ -22,7 +22,7 @@ s2 = 0.01*np.sin(2*np.pi*10*t) + cnse2 plt.subplot(211) -plt.plot(t, s1, 'b-', t, s2, 'g-') +plt.plot(t, s1, t, s2) plt.xlim(0, 5) plt.xlabel('time') plt.ylabel('s1 and s2') diff --git a/examples/pylab_examples/color_by_yvalue.py b/examples/pylab_examples/color_by_yvalue.py index f706a5e8f8c4..59825a1a9a3c 100644 --- a/examples/pylab_examples/color_by_yvalue.py +++ b/examples/pylab_examples/color_by_yvalue.py @@ -13,5 +13,5 @@ slower = np.ma.masked_where(s > lower, s) smiddle = np.ma.masked_where(np.logical_or(s < lower, s > upper), s) -plt.plot(t, slower, 'r', t, smiddle, 'b', t, supper, 'g') +plt.plot(t, smiddle, t, slower, t, supper) plt.show() diff --git a/examples/pylab_examples/csd_demo.py b/examples/pylab_examples/csd_demo.py index 7eaeb850ecad..c988e2c1aa69 100644 --- a/examples/pylab_examples/csd_demo.py +++ b/examples/pylab_examples/csd_demo.py @@ -22,7 +22,7 @@ s2 = 0.01*np.sin(2*np.pi*10*t) + cnse2 plt.subplot(211) -plt.plot(t, s1, 'b-', t, s2, 'g-') +plt.plot(t, s1, t, s2) plt.xlim(0, 5) plt.xlabel('time') plt.ylabel('s1 and s2') diff --git a/examples/pylab_examples/figimage_demo.py b/examples/pylab_examples/figimage_demo.py index 07383ee04bdf..56c78d3bdbf1 100644 --- a/examples/pylab_examples/figimage_demo.py +++ b/examples/pylab_examples/figimage_demo.py @@ -13,7 +13,7 @@ Z.shape = 100, 100 Z[:, 50:] = 1. -im1 = plt.figimage(Z, xo=50, yo=0, cmap=cm.jet, origin='lower') -im2 = plt.figimage(Z, xo=100, yo=100, alpha=.8, cmap=cm.jet, origin='lower') +im1 = plt.figimage(Z, xo=50, yo=0, origin='lower') +im2 = plt.figimage(Z, xo=100, yo=100, alpha=.8, origin='lower') plt.show() diff --git a/examples/pylab_examples/hist_colormapped.py b/examples/pylab_examples/hist_colormapped.py index e3aa1fb59b62..3af198e2d09f 100644 --- a/examples/pylab_examples/hist_colormapped.py +++ b/examples/pylab_examples/hist_colormapped.py @@ -16,7 +16,7 @@ norm = colors.Normalize(fracs.min(), fracs.max()) for thisfrac, thispatch in zip(fracs, patches): - color = cm.jet(norm(thisfrac)) + color = cm.viridis(norm(thisfrac)) thispatch.set_facecolor(color) diff --git a/examples/pylab_examples/image_origin.py b/examples/pylab_examples/image_origin.py index 4effdd66bbee..b00d39c4e8df 100755 --- a/examples/pylab_examples/image_origin.py +++ b/examples/pylab_examples/image_origin.py @@ -15,11 +15,11 @@ lim = -2, 11, -2, 6 plt.subplot(211, facecolor='g') plt.title('blue should be up') -plt.imshow(x, origin='upper', interpolation=interp, cmap='jet') +plt.imshow(x, origin='upper', interpolation=interp) #plt.axis(lim) plt.subplot(212, facecolor='y') plt.title('blue should be down') -plt.imshow(x, origin='lower', interpolation=interp, cmap='jet') +plt.imshow(x, origin='lower', interpolation=interp) #plt.axis(lim) plt.show() diff --git a/examples/pylab_examples/interp_demo.py b/examples/pylab_examples/interp_demo.py index 978afa4cc5bd..9b7c4639eee8 100644 --- a/examples/pylab_examples/interp_demo.py +++ b/examples/pylab_examples/interp_demo.py @@ -9,5 +9,5 @@ yi = stineman_interp(xi, x, y, yp) fig, ax = plt.subplots() -ax.plot(x, y, 'ro', xi, yi, '-b.') +ax.plot(x, y, 'o', xi, yi, '.') plt.show() diff --git a/examples/pylab_examples/layer_images.py b/examples/pylab_examples/layer_images.py index 3756324b3271..a862ac045163 100644 --- a/examples/pylab_examples/layer_images.py +++ b/examples/pylab_examples/layer_images.py @@ -36,7 +36,7 @@ def func3(x, y): Z2 = func3(X, Y) -im2 = plt.imshow(Z2, cmap=plt.cm.jet, alpha=.9, interpolation='bilinear', +im2 = plt.imshow(Z2, cmap=plt.cm.viridis, alpha=.9, interpolation='bilinear', extent=extent) plt.show() diff --git a/examples/pylab_examples/leftventricle_bulleye.py b/examples/pylab_examples/leftventricle_bulleye.py index 889d7d1e9658..35a1f88ee15d 100644 --- a/examples/pylab_examples/leftventricle_bulleye.py +++ b/examples/pylab_examples/leftventricle_bulleye.py @@ -46,7 +46,7 @@ def bullseye_plot(ax, data, segBold=None, cmap=None, norm=None): data = np.array(data).ravel() if cmap is None: - cmap = plt.cm.jet + cmap = plt.cm.viridis if norm is None: 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): # Set the colormap and norm to correspond to the data for which # the colorbar will be used. -cmap = mpl.cm.jet +cmap = mpl.cm.viridis norm = mpl.colors.Normalize(vmin=1, vmax=17) # ColorbarBase derives from ScalarMappable and puts a colorbar diff --git a/examples/pylab_examples/legend_demo5.py b/examples/pylab_examples/legend_demo5.py index 56689660735b..1294cfce4b7a 100644 --- a/examples/pylab_examples/legend_demo5.py +++ b/examples/pylab_examples/legend_demo5.py @@ -52,7 +52,7 @@ def create_artists(self, legend, orig_handle, x = np.linspace(0, 5, 100) plt.figure() -colors = ['red', 'orange', 'yellow', 'green', 'blue'] +colors = plt.rcParams['axes.prop_cycle'].by_key()['color'][:5] styles = ['solid', 'dashed', 'dashed', 'dashed', 'solid'] lines = [] for i, color, style in zip(range(5), colors, styles): diff --git a/examples/pylab_examples/line_collection.py b/examples/pylab_examples/line_collection.py index 2e404559c25b..aefa7d0fe389 100644 --- a/examples/pylab_examples/line_collection.py +++ b/examples/pylab_examples/line_collection.py @@ -30,7 +30,8 @@ # where onoffseq is an even length tuple of on and off ink in points. # If linestyle is omitted, 'solid' is used # See matplotlib.collections.LineCollection for more information -colors = [colorConverter.to_rgba(i) for i in 'bgrcmyk'] +colors = [colorConverter.to_rgba(c) + for c in plt.rcParams['axes.prop_cycle'].by_key()['color']] line_segments = LineCollection(segs, linewidths=(0.5, 1, 1.5, 2), colors=colors, linestyle='solid') diff --git a/examples/pylab_examples/masked_demo.py b/examples/pylab_examples/masked_demo.py index e11963ad51e1..f349aadb5abf 100644 --- a/examples/pylab_examples/masked_demo.py +++ b/examples/pylab_examples/masked_demo.py @@ -15,7 +15,7 @@ ym1 = np.ma.masked_where(y1 > 0.5, y1) ym2 = np.ma.masked_where(y2 < -0.5, y2) -lines = plt.plot(x, y, 'r', x, ym1, 'g', x, ym2, 'bo') +lines = plt.plot(x, y, x, ym1, x, ym2, 'o') plt.setp(lines[0], linewidth=4) plt.setp(lines[1], linewidth=2) plt.setp(lines[2], markersize=10) diff --git a/examples/pylab_examples/multiline.py b/examples/pylab_examples/multiline.py index 9b1da8b446fd..5d0d19a588a1 100644 --- a/examples/pylab_examples/multiline.py +++ b/examples/pylab_examples/multiline.py @@ -32,7 +32,7 @@ plt.xticks([0.2, 0.4, 0.6, 0.8, 1.], ["Jan\n2009", "Feb\n2009", "Mar\n2009", "Apr\n2009", "May\n2009"]) -plt.axhline(0.7) +plt.axhline(0.4) plt.title("test line spacing for multiline text") plt.subplots_adjust(bottom=0.25, top=0.75) diff --git a/examples/pylab_examples/quadmesh_demo.py b/examples/pylab_examples/quadmesh_demo.py index 10707dba16dd..c7e1baa68862 100755 --- a/examples/pylab_examples/quadmesh_demo.py +++ b/examples/pylab_examples/quadmesh_demo.py @@ -32,9 +32,9 @@ ax = fig.add_subplot(122) # You can control the color of the masked region: -#cmap = cm.jet -#cmap.set_bad('r', 1.0) -#ax.pcolormesh(Qx,Qz,Zm, cmap=cmap) +# cmap = cm.RdBu +# cmap.set_bad('y', 1.0) +# ax.pcolormesh(Qx, Qz, Zm, cmap=cmap) # Or use the default, which is transparent: col = ax.pcolormesh(Qx, Qz, Zm, shading='gouraud') ax.set_title('With masked values') diff --git a/examples/pylab_examples/stem_plot.py b/examples/pylab_examples/stem_plot.py index c1b9ec5a2734..6f10003a8e3f 100644 --- a/examples/pylab_examples/stem_plot.py +++ b/examples/pylab_examples/stem_plot.py @@ -3,7 +3,6 @@ x = np.linspace(0.1, 2*np.pi, 10) markerline, stemlines, baseline = plt.stem(x, np.cos(x), '-.') -plt.setp(markerline, 'markerfacecolor', 'b') plt.setp(baseline, 'color', 'r', 'linewidth', 2) plt.show() diff --git a/examples/pylab_examples/stock_demo.py b/examples/pylab_examples/stock_demo.py index 36338d9380e0..306b3ea79b08 100644 --- a/examples/pylab_examples/stock_demo.py +++ b/examples/pylab_examples/stock_demo.py @@ -7,7 +7,7 @@ d1, p1, d2, p2 = get_two_stock_data() fig, ax = plt.subplots() -lines = plt.plot(d1, p1, 'bs', d2, p2, 'go') +lines = plt.plot(d1, p1, 's', d2, p2, 'o') plt.xlabel('Days') plt.ylabel('Normalized price') plt.xlim(0, 3) diff --git a/examples/pylab_examples/subplots_demo.py b/examples/pylab_examples/subplots_demo.py index f8fb8cbf2606..8d54f0535951 100644 --- a/examples/pylab_examples/subplots_demo.py +++ b/examples/pylab_examples/subplots_demo.py @@ -66,6 +66,16 @@ plt.setp([a.get_yticklabels() for a in axarr[:, 1]], visible=False) # Four polar axes -plt.subplots(2, 2, subplot_kw=dict(projection='polar')) +f, axarr = plt.subplots(2, 2, subplot_kw=dict(projection='polar')) +axarr[0, 0].plot(x, y) +axarr[0, 0].set_title('Axis [0,0]') +axarr[0, 1].scatter(x, y) +axarr[0, 1].set_title('Axis [0,1]') +axarr[1, 0].plot(x, y ** 2) +axarr[1, 0].set_title('Axis [1,0]') +axarr[1, 1].scatter(x, y ** 2) +axarr[1, 1].set_title('Axis [1,1]') +# Fine-tune figure; make subplots farther from each other. +f.subplots_adjust(hspace=0.3) plt.show() diff --git a/examples/pylab_examples/vline_hline_demo.py b/examples/pylab_examples/vline_hline_demo.py index 24f9c8119138..d4fe9e0bf306 100644 --- a/examples/pylab_examples/vline_hline_demo.py +++ b/examples/pylab_examples/vline_hline_demo.py @@ -20,12 +20,12 @@ def f(t): vax = fig.add_subplot(121) hax = fig.add_subplot(122) -vax.plot(t, s + nse, 'b^') +vax.plot(t, s + nse, '^') vax.vlines(t, [0], s) vax.set_xlabel('time (s)') vax.set_title('Vertical lines demo') -hax.plot(s + nse, t, 'b^') +hax.plot(s + nse, t, '^') hax.hlines(t, [0], s, lw=2) hax.set_xlabel('time (s)') hax.set_title('Horizontal lines demo') diff --git a/examples/specialty_plots/advanced_hillshading.py b/examples/specialty_plots/advanced_hillshading.py index 92b88f426201..3d6af635e611 100644 --- a/examples/specialty_plots/advanced_hillshading.py +++ b/examples/specialty_plots/advanced_hillshading.py @@ -56,7 +56,7 @@ def shade_other_data(): z2 = np.cos(x**2 + y**2) # Data to color norm = Normalize(z2.min(), z2.max()) - cmap = plt.cm.jet + cmap = plt.cm.RdBu ls = LightSource(315, 45) rgb = ls.shade_rgb(cmap(norm(z2)), z1) diff --git a/examples/style_sheets/plot_dark_background.py b/examples/style_sheets/plot_dark_background.py index c2f76b95e6f5..dd1f0251b324 100644 --- a/examples/style_sheets/plot_dark_background.py +++ b/examples/style_sheets/plot_dark_background.py @@ -12,7 +12,7 @@ L = 6 x = np.linspace(0, L) -ncolors = len(plt.rcParams['axes.color_cycle']) +ncolors = len(plt.rcParams['axes.prop_cycle']) shift = np.linspace(0, L, ncolors, endpoint=False) for s in shift: plt.plot(x, np.sin(x + s), 'o-') diff --git a/examples/style_sheets/plot_ggplot.py b/examples/style_sheets/plot_ggplot.py index 2fff1aac9058..a4fec65ce32e 100644 --- a/examples/style_sheets/plot_ggplot.py +++ b/examples/style_sheets/plot_ggplot.py @@ -25,7 +25,7 @@ # sinusoidal lines with colors from default color cycle L = 2*np.pi x = np.linspace(0, L) -ncolors = len(plt.rcParams['axes.color_cycle']) +ncolors = len(plt.rcParams['axes.prop_cycle']) shift = np.linspace(0, L, ncolors, endpoint=False) for s in shift: ax2.plot(x, np.sin(x + s), '-') @@ -36,14 +36,15 @@ y1, y2 = np.random.randint(1, 25, size=(2, 5)) width = 0.25 ax3.bar(x, y1, width) -ax3.bar(x + width, y2, width, color=plt.rcParams['axes.color_cycle'][2]) +ax3.bar(x + width, y2, width, + color=list(plt.rcParams['axes.prop_cycle'])[2]['color']) ax3.set_xticks(x + width) ax3.set_xticklabels(['a', 'b', 'c', 'd', 'e']) # circles with colors from default color cycle -for i, color in enumerate(plt.rcParams['axes.color_cycle']): +for i, color in enumerate(plt.rcParams['axes.prop_cycle']): xy = np.random.normal(size=2) - ax4.add_patch(plt.Circle(xy, radius=0.3, color=color)) + ax4.add_patch(plt.Circle(xy, radius=0.3, color=color['color'])) ax4.axis('equal') ax4.margins(0) diff --git a/examples/style_sheets/plot_grayscale.py b/examples/style_sheets/plot_grayscale.py index f975fc7c3eb8..e86dccd9932c 100644 --- a/examples/style_sheets/plot_grayscale.py +++ b/examples/style_sheets/plot_grayscale.py @@ -11,7 +11,7 @@ def color_cycle_example(ax): L = 6 x = np.linspace(0, L) - ncolors = len(plt.rcParams['axes.color_cycle']) + ncolors = len(plt.rcParams['axes.prop_cycle']) shift = np.linspace(0, L, ncolors, endpoint=False) for s in shift: ax.plot(x, np.sin(x + s), 'o-') diff --git a/examples/user_interfaces/embedding_in_wx3.py b/examples/user_interfaces/embedding_in_wx3.py index 0d3d57d8d797..a1fd7b65152c 100755 --- a/examples/user_interfaces/embedding_in_wx3.py +++ b/examples/user_interfaces/embedding_in_wx3.py @@ -74,7 +74,7 @@ def init_plot_data(self): y = np.arange(100.0) * 2 * np.pi / 50.0 self.x, self.y = np.meshgrid(x, y) z = np.sin(self.x) + np.cos(self.y) - self.im = a.imshow(z, cmap=cm.jet) # , interpolation='nearest') + self.im = a.imshow(z, cmap=cm.RdBu) # , interpolation='nearest') zmax = np.amax(z) - ERR_TOL ymax_i, xmax_i = np.nonzero(z >= zmax)