From 5adee64b4a6cf21840c7b464784e77cdc83dfaf2 Mon Sep 17 00:00:00 2001 From: endolith Date: Thu, 31 May 2012 00:58:34 -0300 Subject: [PATCH 01/19] use sequential YlOrRd colormap for unipolar data, discourage using jet for everything --- examples/pylab_examples/hexbin_demo.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/examples/pylab_examples/hexbin_demo.py b/examples/pylab_examples/hexbin_demo.py index 4446e2a944f7..d4f3b4ef0f10 100644 --- a/examples/pylab_examples/hexbin_demo.py +++ b/examples/pylab_examples/hexbin_demo.py @@ -20,14 +20,14 @@ plt.subplots_adjust(hspace=0.5) plt.subplot(121) -plt.hexbin(x,y, cmap=cm.jet) +plt.hexbin(x,y, cmap=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=cm.YlOrRd_r) plt.axis([xmin, xmax, ymin, ymax]) plt.title("With a log color scale") cb = plt.colorbar() From 9614b1155c2a175c77efda636c9a17e46c9b7853 Mon Sep 17 00:00:00 2001 From: endolith Date: Thu, 31 May 2012 01:04:18 -0300 Subject: [PATCH 02/19] Jet is discouraged for MRI images. Google Image Search shows the vast majority are grayscale http://www.research.ibm.com/dx/proceedings/pravda/truevis.htm --- examples/pylab_examples/mri_demo.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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() From 5564284cdbdf5606089122c0f27c4741e57080e6 Mon Sep 17 00:00:00 2001 From: endolith Date: Sun, 3 Jun 2012 01:14:11 -0400 Subject: [PATCH 03/19] use HSV for cyclic data --- examples/pylab_examples/polar_scatter.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/examples/pylab_examples/polar_scatter.py b/examples/pylab_examples/polar_scatter.py index 7af26d5b8db1..dd304f52d48e 100644 --- a/examples/pylab_examples/polar_scatter.py +++ b/examples/pylab_examples/polar_scatter.py @@ -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() From c6fac36ed3c5f14c2a9863d9c68f6a8fa068fcbc Mon Sep 17 00:00:00 2001 From: endolith Date: Sun, 3 Jun 2012 01:28:50 -0400 Subject: [PATCH 04/19] fix typos --- examples/pylab_examples/polar_scatter.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/examples/pylab_examples/polar_scatter.py b/examples/pylab_examples/polar_scatter.py index dd304f52d48e..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 From fccaa18ce3bad0e30a58414b49d5e37bdcf22124 Mon Sep 17 00:00:00 2001 From: endolith Date: Mon, 4 Jun 2012 11:12:35 -0400 Subject: [PATCH 05/19] ran a spell-checker on some files --- examples/pylab_examples/agg_buffer_to_array.py | 2 +- examples/pylab_examples/anchored_artists.py | 2 +- examples/pylab_examples/annotation_demo.py | 2 +- examples/pylab_examples/axhspan_demo.py | 2 +- examples/pylab_examples/boxplot_demo2.py | 2 +- examples/pylab_examples/centered_ticklabels.py | 4 ++-- examples/pylab_examples/custom_figure_class.py | 2 +- examples/pylab_examples/custom_ticker1.py | 2 +- examples/pylab_examples/customize_rc.py | 2 +- examples/pylab_examples/date_demo_convert.py | 2 +- examples/pylab_examples/demo_agg_filter.py | 2 +- examples/pylab_examples/fancybox_demo.py | 2 +- examples/pylab_examples/finance_work2.py | 2 +- examples/pylab_examples/ganged_plots.py | 2 +- examples/pylab_examples/major_minor_demo1.py | 2 +- examples/pylab_examples/mathtext_demo.py | 2 +- examples/pylab_examples/polar_demo.py | 2 +- examples/pylab_examples/psd_demo2.py | 2 +- examples/pylab_examples/pythonic_matplotlib.py | 2 +- 19 files changed, 20 insertions(+), 20 deletions(-) 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/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..5cebf5f6b89b 100644 --- a/examples/pylab_examples/customize_rc.py +++ b/examples/pylab_examples/customize_rc.py @@ -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/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/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/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 From a3ed3ab24c7fcb8c96eb8de501614db639538962 Mon Sep 17 00:00:00 2001 From: endolith Date: Mon, 4 Jun 2012 11:17:13 -0400 Subject: [PATCH 06/19] more examples of using sequential colormaps for non-negative data, diverging colormaps for bipolar data --- examples/pylab_examples/colorbar_tick_labelling_demo.py | 4 ++-- examples/pylab_examples/image_nonuniform.py | 8 ++++---- examples/pylab_examples/mri_with_eeg.py | 2 +- examples/pylab_examples/pcolor_log.py | 4 ++-- examples/pylab_examples/specgram_demo.py | 2 +- examples/pylab_examples/subplots_adjust.py | 4 ++-- 6 files changed, 12 insertions(+), 12 deletions(-) diff --git a/examples/pylab_examples/colorbar_tick_labelling_demo.py b/examples/pylab_examples/colorbar_tick_labelling_demo.py index 16f6988e5489..690014510cf4 100644 --- a/examples/pylab_examples/colorbar_tick_labelling_demo.py +++ b/examples/pylab_examples/colorbar_tick_labelling_demo.py @@ -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/image_nonuniform.py b/examples/pylab_examples/image_nonuniform.py index 1f3022377c8d..ca3e10ea7c5b 100644 --- a/examples/pylab_examples/image_nonuniform.py +++ b/examples/pylab_examples/image_nonuniform.py @@ -19,7 +19,7 @@ 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 +27,7 @@ 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 +37,7 @@ 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 +45,7 @@ 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/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_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/specgram_demo.py b/examples/pylab_examples/specgram_demo.py index 95a4703a3168..f0e818fa3c51 100644 --- a/examples/pylab_examples/specgram_demo.py +++ b/examples/pylab_examples/specgram_demo.py @@ -25,5 +25,5 @@ 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]) From b2c672323395b562edc15866fc21845957eeb939 Mon Sep 17 00:00:00 2001 From: endolith Date: Tue, 5 Jun 2012 11:13:39 -0400 Subject: [PATCH 07/19] more typo and spelling fixes --- examples/pylab_examples/set_and_get.py | 6 +++--- examples/pylab_examples/shading_example.py | 2 +- examples/pylab_examples/text_rotation.py | 2 +- examples/pylab_examples/text_rotation_relative_to_line.py | 2 +- 4 files changed, 6 insertions(+), 6 deletions(-) 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/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 From d14700892d94c7bf6f455991a2ac13a182aec136 Mon Sep 17 00:00:00 2001 From: endolith Date: Tue, 5 Jun 2012 11:55:29 -0400 Subject: [PATCH 08/19] coolwarm is specifically designed for diverging data on shaded 3D surfaces --- examples/mplot3d/contour3d_demo.py | 2 +- examples/mplot3d/contour3d_demo2.py | 2 +- examples/mplot3d/contour3d_demo3.py | 6 +++--- examples/mplot3d/contourf3d_demo.py | 2 +- examples/mplot3d/contourf3d_demo2.py | 6 +++--- examples/mplot3d/subplot3d_demo.py | 2 +- examples/mplot3d/surface3d_demo.py | 2 +- 7 files changed, 11 insertions(+), 11 deletions(-) diff --git a/examples/mplot3d/contour3d_demo.py b/examples/mplot3d/contour3d_demo.py index 87eb9551fe18..cf353f6311f0 100644 --- a/examples/mplot3d/contour3d_demo.py +++ b/examples/mplot3d/contour3d_demo.py @@ -4,7 +4,7 @@ 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..c791e9157293 100644 --- a/examples/mplot3d/contour3d_demo2.py +++ b/examples/mplot3d/contour3d_demo2.py @@ -4,7 +4,7 @@ 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..873cc47455d3 100644 --- a/examples/mplot3d/contour3d_demo3.py +++ b/examples/mplot3d/contour3d_demo3.py @@ -5,9 +5,9 @@ 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..8628252cc09d 100644 --- a/examples/mplot3d/contourf3d_demo.py +++ b/examples/mplot3d/contourf3d_demo.py @@ -4,7 +4,7 @@ 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..4c6784a5ccea 100644 --- a/examples/mplot3d/contourf3d_demo2.py +++ b/examples/mplot3d/contourf3d_demo2.py @@ -10,9 +10,9 @@ 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) From fb4a980e9c9f9c673538f09836e061a3c9ccfb7e Mon Sep 17 00:00:00 2001 From: endolith Date: Tue, 5 Jun 2012 12:02:47 -0400 Subject: [PATCH 09/19] sequential map for non-negative surface --- examples/mplot3d/surface3d_radial_demo.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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}$') From f16b15f8ed5551cddd7f3db20d327e3d34b704f9 Mon Sep 17 00:00:00 2001 From: endolith Date: Tue, 5 Jun 2012 12:03:24 -0400 Subject: [PATCH 10/19] rainbow instead of jet for diverging data, summer for sequential data --- examples/pylab_examples/tripcolor_demo.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/examples/pylab_examples/tripcolor_demo.py b/examples/pylab_examples/tripcolor_demo.py index d5dd3ce61218..a3f80082d5e4 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 = 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 = cm.rainbow) plt.colorbar() plt.title('tripcolor with Gouraud shading') @@ -96,7 +96,7 @@ # 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)') From 2df6609940882d914b5476311db3e0999408dfa1 Mon Sep 17 00:00:00 2001 From: endolith Date: Tue, 5 Jun 2012 13:01:18 -0400 Subject: [PATCH 11/19] diverging colormaps with centered norms --- examples/pylab_examples/griddata_demo.py | 2 +- examples/pylab_examples/hexbin_demo2.py | 4 ++-- examples/pylab_examples/image_demo.py | 5 +++-- examples/pylab_examples/pcolor_demo.py | 2 +- examples/pylab_examples/pcolor_demo2.py | 2 +- examples/pylab_examples/poormans_contour.py | 6 +++--- 6 files changed, 11 insertions(+), 10 deletions(-) diff --git a/examples/pylab_examples/griddata_demo.py b/examples/pylab_examples/griddata_demo.py index a72ad3f00ac7..d18bc45f33f6 100644 --- a/examples/pylab_examples/griddata_demo.py +++ b/examples/pylab_examples/griddata_demo.py @@ -16,7 +16,7 @@ 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_demo2.py b/examples/pylab_examples/hexbin_demo2.py index bfa49e3d3134..3dfd3d2d3654 100644 --- a/examples/pylab_examples/hexbin_demo2.py +++ b/examples/pylab_examples/hexbin_demo2.py @@ -39,14 +39,14 @@ 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=cm.RdBu, vmax=abs(z).max(), vmin=-abs(z).max()) # NEEDS NORM 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=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/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/poormans_contour.py b/examples/pylab_examples/poormans_contour.py index a1e5b05d7dff..dc68679f11d3 100644 --- a/examples/pylab_examples/poormans_contour.py +++ b/examples/pylab_examples/poormans_contour.py @@ -18,9 +18,9 @@ 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 - -im = imshow(Z, cmap=cmap, interpolation='bilinear') +cmap = cm.get_cmap('PiYG', 11) # 11 discrete colors +#NORM +im = imshow(Z, cmap=cmap, interpolation='bilinear', vmax=abs(Z).max(), vmin=-abs(Z).max()) axis('off') colorbar() From f3ba478bedf7a3b1d6f9500be50b7cee0a36c44c Mon Sep 17 00:00:00 2001 From: endolith Date: Tue, 5 Jun 2012 13:02:35 -0400 Subject: [PATCH 12/19] better sequential map for showing contours --- examples/pylab_examples/contourf_log.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/pylab_examples/contourf_log.py b/examples/pylab_examples/contourf_log.py index 81d3ad7a28b3..bd948351fede 100644 --- a/examples/pylab_examples/contourf_log.py +++ b/examples/pylab_examples/contourf_log.py @@ -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: From 80008a2249042502984d2760b68022fffe092383 Mon Sep 17 00:00:00 2001 From: endolith Date: Tue, 5 Jun 2012 13:14:46 -0400 Subject: [PATCH 13/19] more complicated example of centered norm diverging colormap --- examples/pylab_examples/contour_image.py | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) 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) From 04409c83ea39a76b4a49a1cd289cab3ccde52a21 Mon Sep 17 00:00:00 2001 From: endolith Date: Tue, 5 Jun 2012 13:26:55 -0400 Subject: [PATCH 14/19] tricontour example rainbow instead of jet, center norm --- examples/pylab_examples/tricontour_vs_griddata.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/examples/pylab_examples/tricontour_vs_griddata.py b/examples/pylab_examples/tricontour_vs_griddata.py index 293cae3ab3e8..3fe5632ca032 100644 --- a/examples/pylab_examples/tricontour_vs_griddata.py +++ b/examples/pylab_examples/tricontour_vs_griddata.py @@ -24,7 +24,7 @@ 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 = 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 +37,7 @@ 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 = Normalize(vmax=abs(zi).max(), vmin=-abs(zi).max())) plt.colorbar() plt.plot(x, y, 'ko', ms=3) plt.xlim(-2,2) From e1b17ec1dab7e3fe4eb2b6a44897499e5f0d80b2 Mon Sep 17 00:00:00 2001 From: endolith Date: Thu, 7 Jun 2012 23:17:10 -0400 Subject: [PATCH 15/19] add imports where needed --- examples/pylab_examples/colorbar_tick_labelling_demo.py | 2 +- examples/pylab_examples/contourf_log.py | 2 +- examples/pylab_examples/customize_rc.py | 2 +- examples/pylab_examples/hexbin_demo.py | 7 +++---- examples/pylab_examples/hexbin_demo2.py | 4 ++-- examples/pylab_examples/image_nonuniform.py | 1 + examples/pylab_examples/tricontour_vs_griddata.py | 4 ++-- examples/pylab_examples/tripcolor_demo.py | 4 ++-- 8 files changed, 13 insertions(+), 13 deletions(-) diff --git a/examples/pylab_examples/colorbar_tick_labelling_demo.py b/examples/pylab_examples/colorbar_tick_labelling_demo.py index 690014510cf4..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 diff --git a/examples/pylab_examples/contourf_log.py b/examples/pylab_examples/contourf_log.py index bd948351fede..841ebbed68d5 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 diff --git a/examples/pylab_examples/customize_rc.py b/examples/pylab_examples/customize_rc.py index 5cebf5f6b89b..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 diff --git a/examples/pylab_examples/hexbin_demo.py b/examples/pylab_examples/hexbin_demo.py index d4f3b4ef0f10..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.YlOrRd_r) +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.YlOrRd_r) +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 3dfd3d2d3654..70dcedb9bdb4 100644 --- a/examples/pylab_examples/hexbin_demo2.py +++ b/examples/pylab_examples/hexbin_demo2.py @@ -39,14 +39,14 @@ gridsize=30 plt.subplot(211) -plt.hexbin(x,y, C=z, gridsize=gridsize, marginals=True, cmap=cm.RdBu, vmax=abs(z).max(), vmin=-abs(z).max()) # NEEDS NORM +plt.hexbin(x,y, C=z, gridsize=gridsize, marginals=True, cmap=plt.cm.RdBu, vmax=abs(z).max(), vmin=-abs(z).max()) # NEEDS NORM plt.axis([xmin, xmax, ymin, ymax]) cb = plt.colorbar() cb.set_label('mean value') plt.subplot(212) -plt.hexbin(x,y, gridsize=gridsize, cmap=cm.Blues_r) +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_nonuniform.py b/examples/pylab_examples/image_nonuniform.py index ca3e10ea7c5b..a2ec606e9ef6 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' diff --git a/examples/pylab_examples/tricontour_vs_griddata.py b/examples/pylab_examples/tricontour_vs_griddata.py index 3fe5632ca032..48a04057fb4a 100644 --- a/examples/pylab_examples/tricontour_vs_griddata.py +++ b/examples/pylab_examples/tricontour_vs_griddata.py @@ -24,7 +24,7 @@ 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.rainbow, norm = Normalize(vmax=abs(zi).max(), vmin=-abs(zi).max())) +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 +37,7 @@ 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.rainbow, norm = Normalize(vmax=abs(zi).max(), vmin=-abs(zi).max())) +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 a3f80082d5e4..506b960019a2 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', cmap = cm.rainbow) +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', cmap = cm.rainbow) +plt.tripcolor(triang, z, shading='gouraud', cmap = plt.cm.rainbow) plt.colorbar() plt.title('tripcolor with Gouraud shading') From 2ac91ec2f22b9b7962714f3a9696114403d3a86d Mon Sep 17 00:00:00 2001 From: endolith Date: Thu, 7 Jun 2012 23:21:01 -0400 Subject: [PATCH 16/19] add imports where needed --- examples/mplot3d/contour3d_demo.py | 1 + examples/mplot3d/contour3d_demo2.py | 1 + examples/mplot3d/contour3d_demo3.py | 1 + examples/mplot3d/contourf3d_demo.py | 1 + examples/mplot3d/contourf3d_demo2.py | 1 + examples/pylab_examples/hexbin_demo2.py | 2 +- 6 files changed, 6 insertions(+), 1 deletion(-) diff --git a/examples/mplot3d/contour3d_demo.py b/examples/mplot3d/contour3d_demo.py index cf353f6311f0..5c49bbfe70fd 100644 --- a/examples/mplot3d/contour3d_demo.py +++ b/examples/mplot3d/contour3d_demo.py @@ -1,5 +1,6 @@ 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') diff --git a/examples/mplot3d/contour3d_demo2.py b/examples/mplot3d/contour3d_demo2.py index c791e9157293..87bef228650c 100644 --- a/examples/mplot3d/contour3d_demo2.py +++ b/examples/mplot3d/contour3d_demo2.py @@ -1,5 +1,6 @@ from mpl_toolkits.mplot3d import axes3d import matplotlib.pyplot as plt +from matplotlib import cm fig = plt.figure() ax = fig.gca(projection='3d') diff --git a/examples/mplot3d/contour3d_demo3.py b/examples/mplot3d/contour3d_demo3.py index 873cc47455d3..790ac617b95d 100644 --- a/examples/mplot3d/contour3d_demo3.py +++ b/examples/mplot3d/contour3d_demo3.py @@ -1,5 +1,6 @@ from mpl_toolkits.mplot3d import axes3d import matplotlib.pyplot as plt +from matplotlib import cm fig = plt.figure() ax = fig.gca(projection='3d') diff --git a/examples/mplot3d/contourf3d_demo.py b/examples/mplot3d/contourf3d_demo.py index 8628252cc09d..cfba939d4d85 100644 --- a/examples/mplot3d/contourf3d_demo.py +++ b/examples/mplot3d/contourf3d_demo.py @@ -1,5 +1,6 @@ from mpl_toolkits.mplot3d import axes3d import matplotlib.pyplot as plt +from matplotlib import cm fig = plt.figure() ax = fig.gca(projection='3d') diff --git a/examples/mplot3d/contourf3d_demo2.py b/examples/mplot3d/contourf3d_demo2.py index 4c6784a5ccea..6e6cc4da5d9f 100644 --- a/examples/mplot3d/contourf3d_demo2.py +++ b/examples/mplot3d/contourf3d_demo2.py @@ -5,6 +5,7 @@ from mpl_toolkits.mplot3d import axes3d import matplotlib.pyplot as plt +from matplotlib import cm fig = plt.figure() ax = fig.gca(projection='3d') diff --git a/examples/pylab_examples/hexbin_demo2.py b/examples/pylab_examples/hexbin_demo2.py index 70dcedb9bdb4..4da5aaba14d4 100644 --- a/examples/pylab_examples/hexbin_demo2.py +++ b/examples/pylab_examples/hexbin_demo2.py @@ -39,7 +39,7 @@ gridsize=30 plt.subplot(211) -plt.hexbin(x,y, C=z, gridsize=gridsize, marginals=True, cmap=plt.cm.RdBu, vmax=abs(z).max(), vmin=-abs(z).max()) # NEEDS NORM +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') From 9231c4c6e619fce1511cd4448676df8f33a82e3b Mon Sep 17 00:00:00 2001 From: endolith Date: Thu, 7 Jun 2012 23:22:43 -0400 Subject: [PATCH 17/19] remove note to self --- examples/pylab_examples/poormans_contour.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/pylab_examples/poormans_contour.py b/examples/pylab_examples/poormans_contour.py index dc68679f11d3..00f4a917caaf 100644 --- a/examples/pylab_examples/poormans_contour.py +++ b/examples/pylab_examples/poormans_contour.py @@ -19,7 +19,7 @@ Z = Z2 - Z1 # difference of Gaussians cmap = cm.get_cmap('PiYG', 11) # 11 discrete colors -#NORM + im = imshow(Z, cmap=cmap, interpolation='bilinear', vmax=abs(Z).max(), vmin=-abs(Z).max()) axis('off') colorbar() From 8a810fa410ffc9e7b10c987ac5235a038e41da08 Mon Sep 17 00:00:00 2001 From: endolith Date: Mon, 18 Jun 2012 11:29:57 -0400 Subject: [PATCH 18/19] style fixes --- examples/mplot3d/contour3d_demo.py | 2 +- examples/mplot3d/contour3d_demo2.py | 2 +- examples/mplot3d/contour3d_demo3.py | 6 +++--- examples/mplot3d/contourf3d_demo.py | 2 +- examples/mplot3d/contourf3d_demo2.py | 6 +++--- examples/pylab_examples/contourf_log.py | 2 +- examples/pylab_examples/griddata_demo.py | 3 ++- examples/pylab_examples/hexbin_demo2.py | 3 ++- examples/pylab_examples/poormans_contour.py | 3 ++- examples/pylab_examples/specgram_demo.py | 3 ++- examples/pylab_examples/tricontour_vs_griddata.py | 6 ++++-- examples/pylab_examples/tripcolor_demo.py | 7 ++++--- 12 files changed, 26 insertions(+), 19 deletions(-) diff --git a/examples/mplot3d/contour3d_demo.py b/examples/mplot3d/contour3d_demo.py index 5c49bbfe70fd..32bb8d3abef6 100644 --- a/examples/mplot3d/contour3d_demo.py +++ b/examples/mplot3d/contour3d_demo.py @@ -5,7 +5,7 @@ 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, cmap = cm.coolwarm) +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 87bef228650c..62e79841942a 100644 --- a/examples/mplot3d/contour3d_demo2.py +++ b/examples/mplot3d/contour3d_demo2.py @@ -5,7 +5,7 @@ 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, cmap = cm.coolwarm) +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 790ac617b95d..125b3bf2fa17 100644 --- a/examples/mplot3d/contour3d_demo3.py +++ b/examples/mplot3d/contour3d_demo3.py @@ -6,9 +6,9 @@ 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, 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) +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 cfba939d4d85..c2c28877ea67 100644 --- a/examples/mplot3d/contourf3d_demo.py +++ b/examples/mplot3d/contourf3d_demo.py @@ -5,7 +5,7 @@ fig = plt.figure() ax = fig.gca(projection='3d') X, Y, Z = axes3d.get_test_data(0.05) -cset = ax.contourf(X, Y, Z, cmap = cm.coolwarm) +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 6e6cc4da5d9f..f20f029acf7a 100644 --- a/examples/mplot3d/contourf3d_demo2.py +++ b/examples/mplot3d/contourf3d_demo2.py @@ -11,9 +11,9 @@ 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, 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) +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/pylab_examples/contourf_log.py b/examples/pylab_examples/contourf_log.py index 841ebbed68d5..de24cf0d2f08 100644 --- a/examples/pylab_examples/contourf_log.py +++ b/examples/pylab_examples/contourf_log.py @@ -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(), cmap = cm.PuBu_r) +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/griddata_demo.py b/examples/pylab_examples/griddata_demo.py index d18bc45f33f6..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.rainbow, vmax=abs(zi).max(), vmin=-abs(zi).max()) +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_demo2.py b/examples/pylab_examples/hexbin_demo2.py index 4da5aaba14d4..8f6a0c5ac265 100644 --- a/examples/pylab_examples/hexbin_demo2.py +++ b/examples/pylab_examples/hexbin_demo2.py @@ -39,7 +39,8 @@ gridsize=30 plt.subplot(211) -plt.hexbin(x,y, C=z, gridsize=gridsize, marginals=True, cmap=plt.cm.RdBu, vmax=abs(z).max(), vmin=-abs(z).max()) +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') diff --git a/examples/pylab_examples/poormans_contour.py b/examples/pylab_examples/poormans_contour.py index 00f4a917caaf..5a518e1a6963 100644 --- a/examples/pylab_examples/poormans_contour.py +++ b/examples/pylab_examples/poormans_contour.py @@ -20,7 +20,8 @@ cmap = cm.get_cmap('PiYG', 11) # 11 discrete colors -im = imshow(Z, cmap=cmap, interpolation='bilinear', vmax=abs(Z).max(), vmin=-abs(Z).max()) +im = imshow(Z, cmap=cmap, interpolation='bilinear', + vmax=abs(Z).max(), vmin=-abs(Z).max()) axis('off') colorbar() diff --git a/examples/pylab_examples/specgram_demo.py b/examples/pylab_examples/specgram_demo.py index f0e818fa3c51..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, cmap=cm.gist_heat) +Pxx, freqs, bins, im = specgram(x, NFFT=NFFT, Fs=Fs, noverlap=900, + cmap=cm.gist_heat) show() diff --git a/examples/pylab_examples/tricontour_vs_griddata.py b/examples/pylab_examples/tricontour_vs_griddata.py index 48a04057fb4a..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.rainbow, norm=plt.normalize(vmax=abs(zi).max(), vmin=-abs(zi).max())) +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.rainbow, norm=plt.normalize(vmax=abs(zi).max(), vmin=-abs(zi).max())) +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 506b960019a2..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', cmap = plt.cm.rainbow) +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', cmap = plt.cm.rainbow) +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', cmap = cm.summer) +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)') From 8b80779622c85c2dcbc45e9fa978f2f56d583e47 Mon Sep 17 00:00:00 2001 From: endolith Date: Mon, 18 Jun 2012 11:33:52 -0400 Subject: [PATCH 19/19] style fixes --- examples/pylab_examples/image_nonuniform.py | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/examples/pylab_examples/image_nonuniform.py b/examples/pylab_examples/image_nonuniform.py index a2ec606e9ef6..74d72f6ae46a 100644 --- a/examples/pylab_examples/image_nonuniform.py +++ b/examples/pylab_examples/image_nonuniform.py @@ -20,7 +20,8 @@ fig = figure() fig.suptitle('NonUniformImage class') ax = fig.add_subplot(221) -im = NonUniformImage(ax, interpolation=interp, extent=(-4,4,-4,4), cmap=cm.Purples) +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) @@ -28,7 +29,8 @@ ax.set_title(interp) ax = fig.add_subplot(222) -im = NonUniformImage(ax, interpolation=interp, extent=(-64,64,-4,4), cmap=cm.Purples) +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) @@ -38,7 +40,8 @@ interp = 'bilinear' ax = fig.add_subplot(223) -im = NonUniformImage(ax, interpolation=interp, extent=(-4,4,-4,4), cmap=cm.Purples) +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) @@ -46,7 +49,8 @@ ax.set_title(interp) ax = fig.add_subplot(224) -im = NonUniformImage(ax, interpolation=interp, extent=(-64,64,-4,4), cmap=cm.Purples) +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)