diff --git a/examples/mplot3d/contour3d_demo.py b/examples/mplot3d/contour3d_demo.py index 87eb9551fe18..32bb8d3abef6 100644 --- a/examples/mplot3d/contour3d_demo.py +++ b/examples/mplot3d/contour3d_demo.py @@ -1,10 +1,11 @@ from mpl_toolkits.mplot3d import axes3d import matplotlib.pyplot as plt +from matplotlib import cm fig = plt.figure() ax = fig.add_subplot(111, projection='3d') X, Y, Z = axes3d.get_test_data(0.05) -cset = ax.contour(X, Y, Z) +cset = ax.contour(X, Y, Z, cmap=cm.coolwarm) ax.clabel(cset, fontsize=9, inline=1) plt.show() diff --git a/examples/mplot3d/contour3d_demo2.py b/examples/mplot3d/contour3d_demo2.py index be9ab883dbe4..62e79841942a 100644 --- a/examples/mplot3d/contour3d_demo2.py +++ b/examples/mplot3d/contour3d_demo2.py @@ -1,10 +1,11 @@ from mpl_toolkits.mplot3d import axes3d import matplotlib.pyplot as plt +from matplotlib import cm fig = plt.figure() ax = fig.gca(projection='3d') X, Y, Z = axes3d.get_test_data(0.05) -cset = ax.contour(X, Y, Z, extend3d=True) +cset = ax.contour(X, Y, Z, extend3d=True, cmap=cm.coolwarm) ax.clabel(cset, fontsize=9, inline=1) plt.show() diff --git a/examples/mplot3d/contour3d_demo3.py b/examples/mplot3d/contour3d_demo3.py index ee6fdac408b2..125b3bf2fa17 100644 --- a/examples/mplot3d/contour3d_demo3.py +++ b/examples/mplot3d/contour3d_demo3.py @@ -1,13 +1,14 @@ from mpl_toolkits.mplot3d import axes3d import matplotlib.pyplot as plt +from matplotlib import cm fig = plt.figure() ax = fig.gca(projection='3d') X, Y, Z = axes3d.get_test_data(0.05) ax.plot_surface(X, Y, Z, rstride=8, cstride=8, alpha=0.3) -cset = ax.contour(X, Y, Z, zdir='z', offset=-100) -cset = ax.contour(X, Y, Z, zdir='x', offset=-40) -cset = ax.contour(X, Y, Z, zdir='y', offset=40) +cset = ax.contour(X, Y, Z, zdir='z', offset=-100, cmap=cm.coolwarm) +cset = ax.contour(X, Y, Z, zdir='x', offset=-40, cmap=cm.coolwarm) +cset = ax.contour(X, Y, Z, zdir='y', offset=40, cmap=cm.coolwarm) ax.set_xlabel('X') ax.set_xlim(-40, 40) diff --git a/examples/mplot3d/contourf3d_demo.py b/examples/mplot3d/contourf3d_demo.py index 171453134f7c..c2c28877ea67 100644 --- a/examples/mplot3d/contourf3d_demo.py +++ b/examples/mplot3d/contourf3d_demo.py @@ -1,10 +1,11 @@ from mpl_toolkits.mplot3d import axes3d import matplotlib.pyplot as plt +from matplotlib import cm fig = plt.figure() ax = fig.gca(projection='3d') X, Y, Z = axes3d.get_test_data(0.05) -cset = ax.contourf(X, Y, Z) +cset = ax.contourf(X, Y, Z, cmap=cm.coolwarm) ax.clabel(cset, fontsize=9, inline=1) plt.show() diff --git a/examples/mplot3d/contourf3d_demo2.py b/examples/mplot3d/contourf3d_demo2.py index 85e2a4412b4d..f20f029acf7a 100644 --- a/examples/mplot3d/contourf3d_demo2.py +++ b/examples/mplot3d/contourf3d_demo2.py @@ -5,14 +5,15 @@ from mpl_toolkits.mplot3d import axes3d import matplotlib.pyplot as plt +from matplotlib import cm fig = plt.figure() ax = fig.gca(projection='3d') X, Y, Z = axes3d.get_test_data(0.05) ax.plot_surface(X, Y, Z, rstride=8, cstride=8, alpha=0.3) -cset = ax.contourf(X, Y, Z, zdir='z', offset=-100) -cset = ax.contourf(X, Y, Z, zdir='x', offset=-40) -cset = ax.contourf(X, Y, Z, zdir='y', offset=40) +cset = ax.contourf(X, Y, Z, zdir='z', offset=-100, cmap=cm.coolwarm) +cset = ax.contourf(X, Y, Z, zdir='x', offset=-40, cmap=cm.coolwarm) +cset = ax.contourf(X, Y, Z, zdir='y', offset=40, cmap=cm.coolwarm) ax.set_xlabel('X') ax.set_xlim(-40, 40) diff --git a/examples/mplot3d/subplot3d_demo.py b/examples/mplot3d/subplot3d_demo.py index 011e2782ec64..23c758fc6b6e 100644 --- a/examples/mplot3d/subplot3d_demo.py +++ b/examples/mplot3d/subplot3d_demo.py @@ -17,7 +17,7 @@ X, Y = np.meshgrid(X, Y) R = np.sqrt(X**2 + Y**2) Z = np.sin(R) -surf = ax.plot_surface(X, Y, Z, rstride=1, cstride=1, cmap=cm.jet, +surf = ax.plot_surface(X, Y, Z, rstride=1, cstride=1, cmap=cm.coolwarm, linewidth=0, antialiased=False) ax.set_zlim3d(-1.01, 1.01) diff --git a/examples/mplot3d/surface3d_demo.py b/examples/mplot3d/surface3d_demo.py index fa14700d18cf..f8c0e28beb81 100644 --- a/examples/mplot3d/surface3d_demo.py +++ b/examples/mplot3d/surface3d_demo.py @@ -11,7 +11,7 @@ X, Y = np.meshgrid(X, Y) R = np.sqrt(X**2 + Y**2) Z = np.sin(R) -surf = ax.plot_surface(X, Y, Z, rstride=1, cstride=1, cmap=cm.jet, +surf = ax.plot_surface(X, Y, Z, rstride=1, cstride=1, cmap=cm.coolwarm, linewidth=0, antialiased=False) ax.set_zlim(-1.01, 1.01) diff --git a/examples/mplot3d/surface3d_radial_demo.py b/examples/mplot3d/surface3d_radial_demo.py index 938866cd07a1..8b1088fcc01d 100644 --- a/examples/mplot3d/surface3d_radial_demo.py +++ b/examples/mplot3d/surface3d_radial_demo.py @@ -18,7 +18,7 @@ X,Y = R*np.cos(P),R*np.sin(P) Z = ((R**2 - 1)**2) -ax.plot_surface(X, Y, Z, rstride=1, cstride=1, cmap=cm.jet) +ax.plot_surface(X, Y, Z, rstride=1, cstride=1, cmap=cm.YlGnBu_r) ax.set_zlim3d(0, 1) ax.set_xlabel(r'$\phi_\mathrm{real}$') ax.set_ylabel(r'$\phi_\mathrm{im}$') diff --git a/examples/pylab_examples/agg_buffer_to_array.py b/examples/pylab_examples/agg_buffer_to_array.py index 8286c583350e..9167ac8b70ea 100644 --- a/examples/pylab_examples/agg_buffer_to_array.py +++ b/examples/pylab_examples/agg_buffer_to_array.py @@ -9,7 +9,7 @@ ax.set_title('a simple figure') fig.canvas.draw() -# grab rhe pixel buffer and dumpy it into a numpy array +# grab the pixel buffer and dump it into a numpy array buf = fig.canvas.buffer_rgba() l, b, w, h = fig.bbox.bounds X = np.frombuffer(buf, np.uint8) diff --git a/examples/pylab_examples/anchored_artists.py b/examples/pylab_examples/anchored_artists.py index 938d47a96293..946f07c9af32 100644 --- a/examples/pylab_examples/anchored_artists.py +++ b/examples/pylab_examples/anchored_artists.py @@ -22,7 +22,7 @@ def __init__(self, transform, size, label, loc, pad=0.1, borderpad=0.1, sep=2, prop=None, frameon=True): """ Draw a horizontal bar with the size in data coordinate of the give axes. - A label will be drawn underneath (center-alinged). + A label will be drawn underneath (center-aligned). pad, borderpad in fraction of the legend font size (or prop) sep in points. diff --git a/examples/pylab_examples/annotation_demo.py b/examples/pylab_examples/annotation_demo.py index 267b0b288f81..913b3a0d9825 100644 --- a/examples/pylab_examples/annotation_demo.py +++ b/examples/pylab_examples/annotation_demo.py @@ -113,7 +113,7 @@ if 1: - # You can also use polar notation on a catesian axes. Here the + # You can also use polar notation on a cartesian axes. Here the # native coordinate system ('data') is cartesian, so you need to # specify the xycoords and textcoords as 'polar' if you want to # use (theta, radius) diff --git a/examples/pylab_examples/axhspan_demo.py b/examples/pylab_examples/axhspan_demo.py index 338c5d690568..ac056e33ad55 100644 --- a/examples/pylab_examples/axhspan_demo.py +++ b/examples/pylab_examples/axhspan_demo.py @@ -14,7 +14,7 @@ # draw a default vline at x=1 that spans the yrange l = plt.axvline(x=1) -# draw a thick blue vline at x=0 that spans the the upper quadrant of +# 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') diff --git a/examples/pylab_examples/boxplot_demo2.py b/examples/pylab_examples/boxplot_demo2.py index 1e7e1171b723..6f4c9ad3e878 100644 --- a/examples/pylab_examples/boxplot_demo2.py +++ b/examples/pylab_examples/boxplot_demo2.py @@ -80,7 +80,7 @@ medianY.append(med.get_ydata()[j]) plt.plot(medianX, medianY, 'k') medians[i] = medianY[0] - # Finally, overplot the sample averages, with horixzontal alignment + # Finally, overplot the sample averages, with horizontal alignment # in the center of each box plt.plot([np.average(med.get_xdata())], [np.average(data[i])], color='w', marker='*', markeredgecolor='k') diff --git a/examples/pylab_examples/centered_ticklabels.py b/examples/pylab_examples/centered_ticklabels.py index 278ab18f0c84..27075f9bd4c5 100644 --- a/examples/pylab_examples/centered_ticklabels.py +++ b/examples/pylab_examples/centered_ticklabels.py @@ -1,10 +1,10 @@ # sometimes it is nice to have ticklabels centered. mpl currently # associates a label with a tick, and the label can be aligned -# 'center', 'feft', or 'right' using the horizontal alignment property: +# 'center', 'left', or 'right' using the horizontal alignment property: # # # for label in ax.xaxis.get_xticklabels(): -# label.set_horizntal_alignment('right') +# label.set_horizontalalignment('right') # # # but this doesn't help center the label between ticks. One solution diff --git a/examples/pylab_examples/colorbar_tick_labelling_demo.py b/examples/pylab_examples/colorbar_tick_labelling_demo.py index 16f6988e5489..63c84232a04e 100644 --- a/examples/pylab_examples/colorbar_tick_labelling_demo.py +++ b/examples/pylab_examples/colorbar_tick_labelling_demo.py @@ -5,7 +5,7 @@ import matplotlib.pyplot as plt import numpy as np - +from matplotlib import cm from numpy.random import randn # Make plot with vertical (default) colorbar @@ -14,7 +14,7 @@ data = np.clip(randn(250, 250), -1, 1) -cax = ax.imshow(data, interpolation='nearest') +cax = ax.imshow(data, interpolation='nearest', cmap=cm.coolwarm) ax.set_title('Gaussian noise with vertical colorbar') # Add colorbar, make sure to specify tick locations to match desired ticklabels @@ -27,7 +27,7 @@ data = np.clip(randn(250, 250), -1, 1) -cax = ax.imshow(data, interpolation='nearest') +cax = ax.imshow(data, interpolation='nearest', cmap=cm.afmhot) ax.set_title('Gaussian noise with horizontal colorbar') cbar = fig.colorbar(cax, ticks=[-1, 0, 1], orientation='horizontal') diff --git a/examples/pylab_examples/contour_image.py b/examples/pylab_examples/contour_image.py index c3d5ce269359..db42fcbcd1c5 100755 --- a/examples/pylab_examples/contour_image.py +++ b/examples/pylab_examples/contour_image.py @@ -26,13 +26,17 @@ levels = arange(-2.0, 1.601, 0.4) # Boost the upper limit to avoid truncation # errors. +norm = cm.colors.Normalize(vmax=abs(Z).max(), vmin=-abs(Z).max()) +cmap = cm.PRGn + figure() subplot(2,2,1) cset1 = contourf(X, Y, Z, levels, - cmap=cm.get_cmap('jet', len(levels)-1), + cmap=cm.get_cmap(cmap, len(levels)-1), + norm=norm, ) # It is not necessary, but for the colormap, we need only the # number of levels minus 1. To avoid discretization error, use @@ -65,7 +69,7 @@ subplot(2,2,2) -imshow(Z, extent=extent) +imshow(Z, extent=extent, cmap=cmap, norm=norm) v = axis() contour(Z, levels, hold='on', colors = 'k', origin='upper', extent=extent) @@ -74,7 +78,7 @@ subplot(2,2,3) -imshow(Z, origin='lower', extent=extent) +imshow(Z, origin='lower', extent=extent, cmap=cmap, norm=norm) v = axis() contour(Z, levels, hold='on', colors = 'k', origin='lower', extent=extent) @@ -89,7 +93,7 @@ # This is intentional. The Z values are defined at the center of each # image pixel (each color block on the following subplot), so the # domain that is contoured does not extend beyond these pixel centers. -im = imshow(Z, interpolation='nearest', extent=extent) +im = imshow(Z, interpolation='nearest', extent=extent, cmap=cmap, norm=norm) v = axis() contour(Z, levels, hold='on', colors = 'k', origin='image', extent=extent) diff --git a/examples/pylab_examples/contourf_log.py b/examples/pylab_examples/contourf_log.py index 81d3ad7a28b3..de24cf0d2f08 100644 --- a/examples/pylab_examples/contourf_log.py +++ b/examples/pylab_examples/contourf_log.py @@ -5,7 +5,7 @@ from matplotlib import pyplot as P import numpy as np from numpy import ma -from matplotlib import colors, ticker +from matplotlib import colors, ticker, cm from matplotlib.mlab import bivariate_normal N = 100 @@ -30,7 +30,7 @@ # Automatic selection of levels works; setting the # log locator tells contourf to use a log scale: -cs = P.contourf(X, Y, z, locator=ticker.LogLocator()) +cs = P.contourf(X, Y, z, locator=ticker.LogLocator(), cmap=cm.PuBu_r) # Alternatively, you can manually set the levels # and the norm: diff --git a/examples/pylab_examples/custom_figure_class.py b/examples/pylab_examples/custom_figure_class.py index 95e72d8d1c7b..c9fa67616c89 100644 --- a/examples/pylab_examples/custom_figure_class.py +++ b/examples/pylab_examples/custom_figure_class.py @@ -1,5 +1,5 @@ """ -You can pass a custom Figure constructor to figure if youy want to derive from the default Figure. This simple example creates a figure with a figure title +You can pass a custom Figure constructor to figure if you want to derive from the default Figure. This simple example creates a figure with a figure title """ from matplotlib.pyplot import figure, show from matplotlib.figure import Figure diff --git a/examples/pylab_examples/custom_ticker1.py b/examples/pylab_examples/custom_ticker1.py index 5ed319915316..d4226c288ade 100644 --- a/examples/pylab_examples/custom_ticker1.py +++ b/examples/pylab_examples/custom_ticker1.py @@ -1,7 +1,7 @@ #!/usr/bin/env python """ -The new ticker code was designed to explicity support user customized +The new ticker code was designed to explicitly support user customized ticking. The documentation http://matplotlib.sourceforge.net/matplotlib.ticker.html details this process. That code defines a lot of preset tickers but was primarily diff --git a/examples/pylab_examples/customize_rc.py b/examples/pylab_examples/customize_rc.py index ed2d8e7afa21..9715f5f96e13 100644 --- a/examples/pylab_examples/customize_rc.py +++ b/examples/pylab_examples/customize_rc.py @@ -1,6 +1,6 @@ """ -I'm not trying to make a good liking figure here, but just to show +I'm not trying to make a good looking figure here, but just to show some examples of customizing rc params on the fly If you like to work interactively, and need to create different sets @@ -36,7 +36,7 @@ def set_pub(): rc('xtick.major', size=5, pad=7) rc('xtick', labelsize=15) -# using aliases for color, linestyle and linewith; gray, solid, thick +# using aliases for color, linestyle and linewidth; gray, solid, thick rc('grid', c='0.5', ls='-', lw=5) rc('lines', lw=2, color='g') subplot(312) diff --git a/examples/pylab_examples/date_demo_convert.py b/examples/pylab_examples/date_demo_convert.py index 4dfabd1e5cb2..d2ad0d096146 100644 --- a/examples/pylab_examples/date_demo_convert.py +++ b/examples/pylab_examples/date_demo_convert.py @@ -17,7 +17,7 @@ ax.plot_date(dates, y*y) # this is superfluous, since the autoscaler should get it right, but -# use date2num and num2date to to convert between dates and floats if +# use date2num and num2date to convert between dates and floats if # you want; both date2num and num2date convert an instance or sequence ax.set_xlim( dates[0], dates[-1] ) diff --git a/examples/pylab_examples/demo_agg_filter.py b/examples/pylab_examples/demo_agg_filter.py index bd8d63b29cb2..48c1b092d80e 100644 --- a/examples/pylab_examples/demo_agg_filter.py +++ b/examples/pylab_examples/demo_agg_filter.py @@ -221,7 +221,7 @@ def filtered_text(ax): def drop_shadow_line(ax): - # copyed from examples/misc/svg_filter_line.py + # copied from examples/misc/svg_filter_line.py # draw lines l1, = ax.plot([0.1, 0.5, 0.9], [0.1, 0.9, 0.5], "bo-", diff --git a/examples/pylab_examples/fancybox_demo.py b/examples/pylab_examples/fancybox_demo.py index 8ada31db3809..324871115f1b 100644 --- a/examples/pylab_examples/fancybox_demo.py +++ b/examples/pylab_examples/fancybox_demo.py @@ -42,7 +42,7 @@ def test1(ax): def test2(ax): # bbox=round has two optional argument. pad and rounding_size. - # They can be set during the initiallization. + # They can be set during the initialization. p_fancy = FancyBboxPatch((bb.xmin, bb.ymin), abs(bb.width), abs(bb.height), boxstyle="round,pad=0.1", diff --git a/examples/pylab_examples/finance_work2.py b/examples/pylab_examples/finance_work2.py index f651d59ef487..0dc2f5f98266 100644 --- a/examples/pylab_examples/finance_work2.py +++ b/examples/pylab_examples/finance_work2.py @@ -95,7 +95,7 @@ def moving_average_convergence(x, nslow=26, nfast=12): fig = plt.figure(facecolor='white') -axescolor = '#f6f6f6' # the axies background color +axescolor = '#f6f6f6' # the axes background color ax1 = fig.add_axes(rect1, axisbg=axescolor) #left, bottom, width, height ax2 = fig.add_axes(rect2, axisbg=axescolor, sharex=ax1) diff --git a/examples/pylab_examples/ganged_plots.py b/examples/pylab_examples/ganged_plots.py index cb45324cb2ef..6e65010b7ae3 100644 --- a/examples/pylab_examples/ganged_plots.py +++ b/examples/pylab_examples/ganged_plots.py @@ -1,7 +1,7 @@ #!/usr/bin/env python """ To create plots that share a common axes (visually) you can set the -hspace bewtween the subplots close to zero (do not use zero itself). +hspace between the subplots close to zero (do not use zero itself). Normally you'll want to turn off the tick labels on all but one of the axes. diff --git a/examples/pylab_examples/griddata_demo.py b/examples/pylab_examples/griddata_demo.py index a72ad3f00ac7..5c11be137d8d 100644 --- a/examples/pylab_examples/griddata_demo.py +++ b/examples/pylab_examples/griddata_demo.py @@ -16,7 +16,8 @@ zi = griddata(x,y,z,xi,yi,interp='linear') # contour the gridded data, plotting dots at the nonuniform data points. CS = plt.contour(xi,yi,zi,15,linewidths=0.5,colors='k') -CS = plt.contourf(xi,yi,zi,15,cmap=plt.cm.jet) +CS = plt.contourf(xi,yi,zi,15,cmap=plt.cm.rainbow, + vmax=abs(zi).max(), vmin=-abs(zi).max()) plt.colorbar() # draw colorbar # plot data points. plt.scatter(x,y,marker='o',c='b',s=5,zorder=10) diff --git a/examples/pylab_examples/hexbin_demo.py b/examples/pylab_examples/hexbin_demo.py index 4446e2a944f7..04f0e073bb09 100644 --- a/examples/pylab_examples/hexbin_demo.py +++ b/examples/pylab_examples/hexbin_demo.py @@ -6,8 +6,7 @@ """ import numpy as np -import matplotlib.cm as cm -import matplotlib.pyplot as plt +import matplotlib.pyplot as plt np.random.seed(0) n = 100000 @@ -20,14 +19,14 @@ plt.subplots_adjust(hspace=0.5) plt.subplot(121) -plt.hexbin(x,y, cmap=cm.jet) +plt.hexbin(x,y, cmap=plt.cm.YlOrRd_r) plt.axis([xmin, xmax, ymin, ymax]) plt.title("Hexagon binning") cb = plt.colorbar() cb.set_label('counts') plt.subplot(122) -plt.hexbin(x,y,bins='log', cmap=cm.jet) +plt.hexbin(x,y,bins='log', cmap=plt.cm.YlOrRd_r) plt.axis([xmin, xmax, ymin, ymax]) plt.title("With a log color scale") cb = plt.colorbar() diff --git a/examples/pylab_examples/hexbin_demo2.py b/examples/pylab_examples/hexbin_demo2.py index bfa49e3d3134..8f6a0c5ac265 100644 --- a/examples/pylab_examples/hexbin_demo2.py +++ b/examples/pylab_examples/hexbin_demo2.py @@ -39,14 +39,15 @@ gridsize=30 plt.subplot(211) -plt.hexbin(x,y, C=z, gridsize=gridsize, marginals=True) +plt.hexbin(x,y, C=z, gridsize=gridsize, marginals=True, cmap=plt.cm.RdBu, + vmax=abs(z).max(), vmin=-abs(z).max()) plt.axis([xmin, xmax, ymin, ymax]) cb = plt.colorbar() cb.set_label('mean value') plt.subplot(212) -plt.hexbin(x,y, gridsize=gridsize) +plt.hexbin(x,y, gridsize=gridsize, cmap=plt.cm.Blues_r) plt.axis([xmin, xmax, ymin, ymax]) cb = plt.colorbar() cb.set_label('N observations') diff --git a/examples/pylab_examples/image_demo.py b/examples/pylab_examples/image_demo.py index d8d5c511127f..f931b910457e 100644 --- a/examples/pylab_examples/image_demo.py +++ b/examples/pylab_examples/image_demo.py @@ -11,8 +11,9 @@ Z2 = mlab.bivariate_normal(X, Y, 1.5, 0.5, 1, 1) Z = Z2-Z1 # difference of Gaussians -im = plt.imshow(Z, interpolation='bilinear', cmap=cm.gray, - origin='lower', extent=[-3,3,-3,3]) +im = plt.imshow(Z, interpolation='bilinear', cmap=cm.RdYlGn, + origin='lower', extent=[-3,3,-3,3], + vmax=abs(Z).max(), vmin=-abs(Z).max()) plt.show() diff --git a/examples/pylab_examples/image_nonuniform.py b/examples/pylab_examples/image_nonuniform.py index 1f3022377c8d..74d72f6ae46a 100644 --- a/examples/pylab_examples/image_nonuniform.py +++ b/examples/pylab_examples/image_nonuniform.py @@ -7,6 +7,7 @@ from matplotlib.pyplot import figure, show import numpy as np from matplotlib.image import NonUniformImage +from matplotlib import cm interp='nearest' @@ -19,7 +20,8 @@ fig = figure() fig.suptitle('NonUniformImage class') ax = fig.add_subplot(221) -im = NonUniformImage(ax, interpolation=interp, extent=(-4,4,-4,4)) +im = NonUniformImage(ax, interpolation=interp, extent=(-4,4,-4,4), + cmap=cm.Purples) im.set_data(x, y, z) ax.images.append(im) ax.set_xlim(-4,4) @@ -27,7 +29,8 @@ ax.set_title(interp) ax = fig.add_subplot(222) -im = NonUniformImage(ax, interpolation=interp, extent=(-64,64,-4,4)) +im = NonUniformImage(ax, interpolation=interp, extent=(-64,64,-4,4), + cmap=cm.Purples) im.set_data(x2, y, z) ax.images.append(im) ax.set_xlim(-64,64) @@ -37,7 +40,8 @@ interp = 'bilinear' ax = fig.add_subplot(223) -im = NonUniformImage(ax, interpolation=interp, extent=(-4,4,-4,4)) +im = NonUniformImage(ax, interpolation=interp, extent=(-4,4,-4,4), + cmap=cm.Purples) im.set_data(x, y, z) ax.images.append(im) ax.set_xlim(-4,4) @@ -45,7 +49,8 @@ ax.set_title(interp) ax = fig.add_subplot(224) -im = NonUniformImage(ax, interpolation=interp, extent=(-64,64,-4,4)) +im = NonUniformImage(ax, interpolation=interp, extent=(-64,64,-4,4), + cmap=cm.Purples) im.set_data(x2, y, z) ax.images.append(im) ax.set_xlim(-64,64) diff --git a/examples/pylab_examples/major_minor_demo1.py b/examples/pylab_examples/major_minor_demo1.py index 562fd9712373..81090b065d7a 100644 --- a/examples/pylab_examples/major_minor_demo1.py +++ b/examples/pylab_examples/major_minor_demo1.py @@ -19,7 +19,7 @@ some base. The FormatStrFormatter uses a string format string (eg '%d' or '%1.2f' or '%1.1f cm' ) to format the tick -The pylab interface grid command chnages the grid settings of the +The pylab interface grid command changes the grid settings of the major ticks of the y and y axis together. If you want to control the grid of the minor ticks for a given axis, use for example diff --git a/examples/pylab_examples/mathtext_demo.py b/examples/pylab_examples/mathtext_demo.py index 333816cdbeb2..232e5df1fc76 100644 --- a/examples/pylab_examples/mathtext_demo.py +++ b/examples/pylab_examples/mathtext_demo.py @@ -1,6 +1,6 @@ #!/usr/bin/env python """ -Use matplotlib's internal LaTex parser and layout engine. For true +Use matplotlib's internal LaTeX parser and layout engine. For true latex rendering, see the text.usetex option """ import numpy as np diff --git a/examples/pylab_examples/mri_demo.py b/examples/pylab_examples/mri_demo.py index df7e875bd3ab..84f93532eba3 100755 --- a/examples/pylab_examples/mri_demo.py +++ b/examples/pylab_examples/mri_demo.py @@ -10,7 +10,7 @@ im.shape = 256, 256 #imshow(im, ColormapJet(256)) -imshow(im, cmap=cm.jet) +imshow(im, cmap=cm.gray) axis('off') show() diff --git a/examples/pylab_examples/mri_with_eeg.py b/examples/pylab_examples/mri_with_eeg.py index 20ad4f459c4b..a7107862207f 100755 --- a/examples/pylab_examples/mri_with_eeg.py +++ b/examples/pylab_examples/mri_with_eeg.py @@ -22,7 +22,7 @@ if 1: # plot the MRI in pcolor subplot(221) - imshow(im, cmap=cm.jet) + imshow(im, cmap=cm.gray) axis('off') if 1: # plot the histogram of MRI intensity diff --git a/examples/pylab_examples/pcolor_demo.py b/examples/pylab_examples/pcolor_demo.py index ee0e3da51c78..015b4a7f63d8 100644 --- a/examples/pylab_examples/pcolor_demo.py +++ b/examples/pylab_examples/pcolor_demo.py @@ -19,7 +19,7 @@ def func3(x,y): X,Y = meshgrid(x, y) Z = func3(X, Y) -pcolor(X, Y, Z) +pcolor(X, Y, Z, cmap=cm.RdBu, vmax=abs(Z).max(), vmin=-abs(Z).max()) colorbar() axis([-3,3,-3,3]) diff --git a/examples/pylab_examples/pcolor_demo2.py b/examples/pylab_examples/pcolor_demo2.py index e917d091c53a..f5ae2c9fa3ea 100644 --- a/examples/pylab_examples/pcolor_demo2.py +++ b/examples/pylab_examples/pcolor_demo2.py @@ -20,7 +20,7 @@ def func3(x,y): ax = subplot(111) -im = imshow(Z, cmap=cm.jet) +im = imshow(Z, cmap=cm.RdBu, vmax=abs(Z).max(), vmin=-abs(Z).max()) #im.set_interpolation('nearest') #im.set_interpolation('bicubic') im.set_interpolation('bilinear') diff --git a/examples/pylab_examples/pcolor_log.py b/examples/pylab_examples/pcolor_log.py index 163ce0814bdf..4cdb9bf2a2bb 100644 --- a/examples/pylab_examples/pcolor_log.py +++ b/examples/pylab_examples/pcolor_log.py @@ -15,11 +15,11 @@ Z1 = bivariate_normal(X, Y, 0.1, 0.2, 1.0, 1.0) + 0.1*bivariate_normal(X, Y, 1.0, 1.0, 0.0, 0.0) subplot(2,1,1) -pcolor(X, Y, Z1, norm=LogNorm(vmin=Z1.min(), vmax=Z1.max())) +pcolor(X, Y, Z1, norm=LogNorm(vmin=Z1.min(), vmax=Z1.max()), cmap=cm.PuBu_r) colorbar() subplot(2,1,2) -pcolor(X, Y, Z1) +pcolor(X, Y, Z1, cmap=cm.PuBu_r) colorbar() diff --git a/examples/pylab_examples/polar_demo.py b/examples/pylab_examples/polar_demo.py index 35c91c02d5bb..0c27aeeb24bb 100644 --- a/examples/pylab_examples/polar_demo.py +++ b/examples/pylab_examples/polar_demo.py @@ -9,7 +9,7 @@ # PolarAxes) -- other axes plotting functions may work on PolarAxes # but haven't been tested and may need tweaking. # -# you can get get a PolarSubplot instance by doing, for example +# you can get a PolarSubplot instance by doing, for example # # subplot(211, polar=True) # diff --git a/examples/pylab_examples/polar_scatter.py b/examples/pylab_examples/polar_scatter.py index 7af26d5b8db1..196f6e847290 100644 --- a/examples/pylab_examples/polar_scatter.py +++ b/examples/pylab_examples/polar_scatter.py @@ -1,8 +1,8 @@ #!/usr/bin/env python # a polar scatter plot; size increases radially in this example and # color increases with angle (just to verify the symbols are being -# scattered correctlu). In a real example, this would be wasting -# dimensionlaity of the plot +# scattered correctly). In a real example, this would be wasting +# dimensionality of the plot from pylab import * N = 150 @@ -11,8 +11,7 @@ area = 200*r**2*rand(N) colors = theta ax = subplot(111, polar=True) -c = scatter(theta, r, c=colors, s=area) +c = scatter(theta, r, c=colors, s=area, cmap=cm.hsv) c.set_alpha(0.75) - show() diff --git a/examples/pylab_examples/poormans_contour.py b/examples/pylab_examples/poormans_contour.py index a1e5b05d7dff..5a518e1a6963 100644 --- a/examples/pylab_examples/poormans_contour.py +++ b/examples/pylab_examples/poormans_contour.py @@ -18,9 +18,10 @@ Z2 = bivariate_normal(X, Y, 1.5, 0.5, 1, 1) Z = Z2 - Z1 # difference of Gaussians -cmap = cm.get_cmap('jet', 10) # 10 discrete colors +cmap = cm.get_cmap('PiYG', 11) # 11 discrete colors -im = imshow(Z, cmap=cmap, interpolation='bilinear') +im = imshow(Z, cmap=cmap, interpolation='bilinear', + vmax=abs(Z).max(), vmin=-abs(Z).max()) axis('off') colorbar() diff --git a/examples/pylab_examples/psd_demo2.py b/examples/pylab_examples/psd_demo2.py index c7265524cd0e..08d452b84fc9 100644 --- a/examples/pylab_examples/psd_demo2.py +++ b/examples/pylab_examples/psd_demo2.py @@ -22,7 +22,7 @@ ax2.psd(y, NFFT=len(t), pad_to=len(t)*4, Fs=fs) plt.title('zero padding') -#Plot the PSD with different block sizes, Zero pad to the length of the orignal +#Plot the PSD with different block sizes, Zero pad to the length of the original #data sequence. ax3 = fig.add_subplot(2, 3, 5, sharex=ax2, sharey=ax2) ax3.psd(y, NFFT=len(t), pad_to=len(t), Fs=fs) diff --git a/examples/pylab_examples/pythonic_matplotlib.py b/examples/pylab_examples/pythonic_matplotlib.py index c8b54664eca8..16e822070113 100644 --- a/examples/pylab_examples/pythonic_matplotlib.py +++ b/examples/pylab_examples/pythonic_matplotlib.py @@ -1,7 +1,7 @@ #!/usr/bin/env python """ Some people prefer to write more pythonic, object oriented, code -rather than use the pylab interface to matplotlib. This example show +rather than use the pylab interface to matplotlib. This example shows you how. Unless you are an application developer, I recommend using part of the diff --git a/examples/pylab_examples/set_and_get.py b/examples/pylab_examples/set_and_get.py index 21e40ad823f7..7ca05540a4b5 100644 --- a/examples/pylab_examples/set_and_get.py +++ b/examples/pylab_examples/set_and_get.py @@ -21,8 +21,8 @@ >>> setp(line) set operates on a single instance or a list of instances. If you are - in quey mode introspecting the possible values, only the first - instance in the sequnce is used. When actually setting values, all + in query mode introspecting the possible values, only the first + instance in the sequence is used. When actually setting values, all the instances will be set. Eg, suppose you have a list of two lines, the following will make both lines thicker and red @@ -52,7 +52,7 @@ color = b ... long listing skipped ... -Alisases: +Aliases: To reduce keystrokes in interactive mode, a number of properties have short aliases, eg 'lw' for 'linewidth' and 'mec' for diff --git a/examples/pylab_examples/shading_example.py b/examples/pylab_examples/shading_example.py index a70791f78d7a..c71395e33d53 100644 --- a/examples/pylab_examples/shading_example.py +++ b/examples/pylab_examples/shading_example.py @@ -3,7 +3,7 @@ from matplotlib.colors import LightSource # example showing how to make shaded relief plots -# like mathematica +# like Mathematica # (http://reference.wolfram.com/mathematica/ref/ReliefPlot.html) # or Generic Mapping Tools # (http://gmt.soest.hawaii.edu/gmt/doc/gmt/html/GMT_Docs/node145.html) diff --git a/examples/pylab_examples/specgram_demo.py b/examples/pylab_examples/specgram_demo.py index 95a4703a3168..70c1a650dd4c 100644 --- a/examples/pylab_examples/specgram_demo.py +++ b/examples/pylab_examples/specgram_demo.py @@ -25,5 +25,6 @@ ax1 = subplot(211) plot(t, x) subplot(212, sharex=ax1) -Pxx, freqs, bins, im = specgram(x, NFFT=NFFT, Fs=Fs, noverlap=900) +Pxx, freqs, bins, im = specgram(x, NFFT=NFFT, Fs=Fs, noverlap=900, + cmap=cm.gist_heat) show() diff --git a/examples/pylab_examples/subplots_adjust.py b/examples/pylab_examples/subplots_adjust.py index 91584bc3018b..5231c83eda79 100644 --- a/examples/pylab_examples/subplots_adjust.py +++ b/examples/pylab_examples/subplots_adjust.py @@ -2,9 +2,9 @@ subplot(211) -imshow(rand(100,100)) +imshow(rand(100,100), cmap=cm.BuPu_r) subplot(212) -imshow(rand(100,100)) +imshow(rand(100,100), cmap=cm.BuPu_r) subplots_adjust(bottom=0.1, right=0.8, top=0.9) cax = axes([0.85, 0.1, 0.075, 0.8]) diff --git a/examples/pylab_examples/text_rotation.py b/examples/pylab_examples/text_rotation.py index 2a3fa2dc5264..083bf7d433ae 100644 --- a/examples/pylab_examples/text_rotation.py +++ b/examples/pylab_examples/text_rotation.py @@ -1,6 +1,6 @@ #!/usr/bin/env python """ -The way matplotlib does text layout is counter-intuituve to some, so +The way matplotlib does text layout is counter-intuitive to some, so this example is designed to make it a little clearer. The text is aligned by it's bounding box (the rectangular box that surrounds the ink rectangle). The order of operations is basically rotation then diff --git a/examples/pylab_examples/text_rotation_relative_to_line.py b/examples/pylab_examples/text_rotation_relative_to_line.py index dcbfa54f079c..a2a08c506f49 100644 --- a/examples/pylab_examples/text_rotation_relative_to_line.py +++ b/examples/pylab_examples/text_rotation_relative_to_line.py @@ -2,7 +2,7 @@ """ Text objects in matplotlib are normally rotated with respect to the screen coordinate system (i.e., 45 degrees rotation plots text along a -line that is inbetween horizontal and vertical no matter how the axes +line that is in between horizontal and vertical no matter how the axes are changed). However, at times one wants to rotate text with respect to something on the plot. In this case, the correct angle won't be the angle of that object in the plot coordinate system, but the angle diff --git a/examples/pylab_examples/tricontour_vs_griddata.py b/examples/pylab_examples/tricontour_vs_griddata.py index 293cae3ab3e8..a30b23dca76d 100644 --- a/examples/pylab_examples/tricontour_vs_griddata.py +++ b/examples/pylab_examples/tricontour_vs_griddata.py @@ -24,7 +24,8 @@ yi = np.linspace(-2.1,2.1,ngridy) zi = griddata(x,y,z,xi,yi,interp='linear') plt.contour(xi,yi,zi,15,linewidths=0.5,colors='k') -plt.contourf(xi,yi,zi,15,cmap=plt.cm.jet) +plt.contourf(xi,yi,zi,15,cmap=plt.cm.rainbow, + norm=plt.normalize(vmax=abs(zi).max(), vmin=-abs(zi).max())) plt.colorbar() # draw colorbar plt.plot(x, y, 'ko', ms=3) plt.xlim(-2,2) @@ -37,7 +38,8 @@ plt.subplot(212) triang = tri.Triangulation(x, y) plt.tricontour(x, y, z, 15, linewidths=0.5, colors='k') -plt.tricontourf(x, y, z, 15, cmap=plt.cm.jet) +plt.tricontourf(x, y, z, 15, cmap=plt.cm.rainbow, + norm=plt.normalize(vmax=abs(zi).max(), vmin=-abs(zi).max())) plt.colorbar() plt.plot(x, y, 'ko', ms=3) plt.xlim(-2,2) diff --git a/examples/pylab_examples/tripcolor_demo.py b/examples/pylab_examples/tripcolor_demo.py index d5dd3ce61218..bb8757617143 100644 --- a/examples/pylab_examples/tripcolor_demo.py +++ b/examples/pylab_examples/tripcolor_demo.py @@ -35,14 +35,14 @@ # pcolor plot. plt.figure() plt.gca().set_aspect('equal') -plt.tripcolor(triang, z, shading='flat') +plt.tripcolor(triang, z, shading='flat', cmap=plt.cm.rainbow) plt.colorbar() plt.title('tripcolor of Delaunay triangulation: flat') # Illustrate Gouraud shading. plt.figure() plt.gca().set_aspect('equal') -plt.tripcolor(triang, z, shading='gouraud') +plt.tripcolor(triang, z, shading='gouraud', cmap=plt.cm.rainbow) plt.colorbar() plt.title('tripcolor with Gouraud shading') @@ -96,7 +96,8 @@ # calculations. plt.figure() plt.gca().set_aspect('equal') -plt.tripcolor(x, y, triangles, z, shading='flat', edgecolors='k') +plt.tripcolor(x, y, triangles, z, shading='flat', edgecolors='k', + cmap=cm.summer) plt.colorbar() plt.title('tripcolor of user-specified triangulation') plt.xlabel('Longitude (degrees)')