From 5cba226e10128d1c9b1a3d79ac0c9555acf957dc Mon Sep 17 00:00:00 2001 From: Thomas Hisch Date: Sun, 9 Nov 2014 14:48:09 +0100 Subject: [PATCH 01/26] fix trailing whitespace --- examples/misc/svg_filter_pie.py | 8 ++++---- examples/mplot3d/mixed_subplots_demo.py | 2 +- examples/pylab_examples/README | 2 +- examples/pylab_examples/broken_axis.py | 2 +- examples/pylab_examples/demo_text_path.py | 2 +- examples/pylab_examples/fancybox_demo.py | 4 ++-- examples/pylab_examples/fancytextbox_demo.py | 4 ++-- examples/pylab_examples/hexbin_demo2.py | 2 +- examples/pylab_examples/image_nonuniform.py | 8 ++++---- examples/pylab_examples/multiple_yaxis_with_spines.py | 4 ++-- examples/pylab_examples/scatter_hist.py | 2 +- examples/pylab_examples/specgram_demo.py | 4 ++-- examples/statistics/violinplot_demo.py | 4 ++-- examples/style_sheets/plot_bmh.py | 2 +- examples/style_sheets/plot_fivethirtyeight.py | 2 +- examples/user_interfaces/fourier_demo_wx.py | 6 +++--- 16 files changed, 29 insertions(+), 29 deletions(-) diff --git a/examples/misc/svg_filter_pie.py b/examples/misc/svg_filter_pie.py index 924807c060f5..ffb79e3c8e76 100644 --- a/examples/misc/svg_filter_pie.py +++ b/examples/misc/svg_filter_pie.py @@ -3,7 +3,7 @@ The pie chart drawing code is borrowed from pie_demo.py Note that the filtering effects are only effective if your svg rederer -support it. +support it. """ @@ -62,16 +62,16 @@ - + - - diff --git a/examples/mplot3d/mixed_subplots_demo.py b/examples/mplot3d/mixed_subplots_demo.py index 4fbd4df875bd..cca9cc604cdc 100644 --- a/examples/mplot3d/mixed_subplots_demo.py +++ b/examples/mplot3d/mixed_subplots_demo.py @@ -23,7 +23,7 @@ def f(t): fig = plt.figure(figsize=plt.figaspect(2.)) fig.suptitle('A tale of 2 subplots') ax = fig.add_subplot(2, 1, 1) -l = ax.plot(t1, f(t1), 'bo', +l = ax.plot(t1, f(t1), 'bo', t2, f(t2), 'k--', markerfacecolor='green') ax.grid(True) ax.set_ylabel('Damped oscillation') diff --git a/examples/pylab_examples/README b/examples/pylab_examples/README index e45e071ea9ce..ca0d48e04541 100644 --- a/examples/pylab_examples/README +++ b/examples/pylab_examples/README @@ -1,4 +1,4 @@ -Here are some demos of how to use the matplotlib. +Here are some demos of how to use the matplotlib. -- data_helper.py - a convenience module to load some data from the diff --git a/examples/pylab_examples/broken_axis.py b/examples/pylab_examples/broken_axis.py index f6cb3cabf20c..b44951810a23 100644 --- a/examples/pylab_examples/broken_axis.py +++ b/examples/pylab_examples/broken_axis.py @@ -11,7 +11,7 @@ 0.043, 0.021, 0.138, 0.075, 0.109, 0.195, 0.05 , 0.074, 0.079, 0.155, 0.02 , 0.01 , 0.061, 0.008]) -# Now let's make two outlier points which are far away from everything. +# Now let's make two outlier points which are far away from everything. pts[[3, 14]] += .8 # If we were to simply plot pts, we'd lose most of the interesting diff --git a/examples/pylab_examples/demo_text_path.py b/examples/pylab_examples/demo_text_path.py index 91ca65ab993a..40292f567fd4 100644 --- a/examples/pylab_examples/demo_text_path.py +++ b/examples/pylab_examples/demo_text_path.py @@ -92,7 +92,7 @@ def draw(self, renderer=None): p1 = PathPatch(text_path, ec="w", lw=3, fc="w", alpha=0.9, transform=IdentityTransform()) - p2 = PathPatch(text_path, ec="none", fc="k", + p2 = PathPatch(text_path, ec="none", fc="k", transform=IdentityTransform()) offsetbox2 = AuxTransformBox(IdentityTransform()) diff --git a/examples/pylab_examples/fancybox_demo.py b/examples/pylab_examples/fancybox_demo.py index 79b43e6e34c4..410fbf8890ee 100644 --- a/examples/pylab_examples/fancybox_demo.py +++ b/examples/pylab_examples/fancybox_demo.py @@ -10,7 +10,7 @@ def draw_bbox(ax, bb): # boxstyle=square with pad=0, i.e. bbox itself. p_bbox = FancyBboxPatch((bb.xmin, bb.ymin), - abs(bb.width), abs(bb.height), + abs(bb.width), abs(bb.height), boxstyle="square,pad=0.", ec="k", fc="none", zorder=10., ) @@ -113,7 +113,7 @@ def test4(ax): p_fancy = FancyBboxPatch((bb.xmin, bb.ymin), abs(bb.width), abs(bb.height), boxstyle="round,pad=0.3", - mutation_aspect=.5, + mutation_aspect=.5, fc=(1., 0.8, 1.), ec=(1., 0.5, 1.)) diff --git a/examples/pylab_examples/fancytextbox_demo.py b/examples/pylab_examples/fancytextbox_demo.py index 11f37ba77345..1fa56e3ba920 100644 --- a/examples/pylab_examples/fancytextbox_demo.py +++ b/examples/pylab_examples/fancytextbox_demo.py @@ -1,7 +1,7 @@ import matplotlib.pyplot as plt plt.text(0.6, 0.5, "test", size=50, rotation=30., - ha="center", va="center", + ha="center", va="center", bbox=dict(boxstyle="round", ec=(1., 0.5, 0.5), fc=(1., 0.8, 0.8), @@ -9,7 +9,7 @@ ) plt.text(0.5, 0.4, "test", size=50, rotation=-30., - ha="right", va="top", + ha="right", va="top", bbox=dict(boxstyle="square", ec=(1., 0.5, 0.5), fc=(1., 0.8, 0.8), diff --git a/examples/pylab_examples/hexbin_demo2.py b/examples/pylab_examples/hexbin_demo2.py index 6d8f74752c92..44f858bc591f 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, +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() diff --git a/examples/pylab_examples/image_nonuniform.py b/examples/pylab_examples/image_nonuniform.py index c488504c86c7..b073593c9403 100644 --- a/examples/pylab_examples/image_nonuniform.py +++ b/examples/pylab_examples/image_nonuniform.py @@ -20,7 +20,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) @@ -29,7 +29,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) @@ -40,7 +40,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) @@ -49,7 +49,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) diff --git a/examples/pylab_examples/multiple_yaxis_with_spines.py b/examples/pylab_examples/multiple_yaxis_with_spines.py index ebe46354147f..98532d31b047 100644 --- a/examples/pylab_examples/multiple_yaxis_with_spines.py +++ b/examples/pylab_examples/multiple_yaxis_with_spines.py @@ -16,8 +16,8 @@ def make_patch_spines_invisible(ax): # Offset the right spine of par2. The ticks and label have already been # placed on the right by twinx above. par2.spines["right"].set_position(("axes", 1.2)) -# Having been created by twinx, par2 has its frame off, so the line of its -# detached spine is invisible. First, activate the frame but make the patch +# Having been created by twinx, par2 has its frame off, so the line of its +# detached spine is invisible. First, activate the frame but make the patch # and spines invisible. make_patch_spines_invisible(par2) # Second, show the right spine. diff --git a/examples/pylab_examples/scatter_hist.py b/examples/pylab_examples/scatter_hist.py index 098520df188e..16ee2e0d1d2c 100644 --- a/examples/pylab_examples/scatter_hist.py +++ b/examples/pylab_examples/scatter_hist.py @@ -8,7 +8,7 @@ nullfmt = NullFormatter() # no labels -# definitions for the axes +# definitions for the axes left, width = 0.1, 0.65 bottom, height = 0.1, 0.65 bottom_h = left_h = left+width+0.02 diff --git a/examples/pylab_examples/specgram_demo.py b/examples/pylab_examples/specgram_demo.py index d5cced232d7b..edfc4c38fbaf 100644 --- a/examples/pylab_examples/specgram_demo.py +++ b/examples/pylab_examples/specgram_demo.py @@ -24,7 +24,7 @@ ax1 = subplot(211) plot(t, x) -subplot(212, sharex=ax1) -Pxx, freqs, bins, im = specgram(x, NFFT=NFFT, Fs=Fs, noverlap=900, +subplot(212, sharex=ax1) +Pxx, freqs, bins, im = specgram(x, NFFT=NFFT, Fs=Fs, noverlap=900, cmap=cm.gist_heat) show() diff --git a/examples/statistics/violinplot_demo.py b/examples/statistics/violinplot_demo.py index 35c3c365b702..1bfcccf061e0 100644 --- a/examples/statistics/violinplot_demo.py +++ b/examples/statistics/violinplot_demo.py @@ -13,11 +13,11 @@ fig, axes = plt.subplots(nrows=2, ncols=3, figsize=(6, 6)) -axes[0, 0].violinplot(data, pos, points=20, widths=0.1, +axes[0, 0].violinplot(data, pos, points=20, widths=0.1, showmeans=True, showextrema=True, showmedians=True) axes[0, 0].set_title('Custom violinplot 1', fontsize=fs) -axes[0, 1].violinplot(data, pos, points=40, widths=0.3, +axes[0, 1].violinplot(data, pos, points=40, widths=0.3, showmeans=True, showextrema=True, showmedians=True, bw_method='silverman') axes[0, 1].set_title('Custom violinplot 2', fontsize=fs) diff --git a/examples/style_sheets/plot_bmh.py b/examples/style_sheets/plot_bmh.py index 0f2fef624a86..f44c319a675e 100644 --- a/examples/style_sheets/plot_bmh.py +++ b/examples/style_sheets/plot_bmh.py @@ -1,5 +1,5 @@ """ -This example demonstrates the "bmh" style, which is the design used in the +This example demonstrates the "bmh" style, which is the design used in the Bayesian Methods for Hackers online book. """ from numpy.random import beta diff --git a/examples/style_sheets/plot_fivethirtyeight.py b/examples/style_sheets/plot_fivethirtyeight.py index 4bed0a5d2dde..21f919274366 100644 --- a/examples/style_sheets/plot_fivethirtyeight.py +++ b/examples/style_sheets/plot_fivethirtyeight.py @@ -1,5 +1,5 @@ """ -This shows an example of the "fivethirtyeight" styling, which +This shows an example of the "fivethirtyeight" styling, which tries to replicate the styles from FiveThirtyEight.com. """ diff --git a/examples/user_interfaces/fourier_demo_wx.py b/examples/user_interfaces/fourier_demo_wx.py index c0c718799e99..e5652b805727 100644 --- a/examples/user_interfaces/fourier_demo_wx.py +++ b/examples/user_interfaces/fourier_demo_wx.py @@ -11,7 +11,7 @@ class Knob(object): """ - Knob - simple class with a "setKnob" method. + Knob - simple class with a "setKnob" method. A Knob instance is attached to a Param instance, e.g., param.attach(knob) Base class is for documentation purposes. """ @@ -25,8 +25,8 @@ class Param(object): The idea of the "Param" class is that some parameter in the GUI may have several knobs that both control it and reflect the parameter's state, e.g. a slider, text, and dragging can all change the value of the frequency in - the waveform of this example. - The class allows a cleaner way to update/"feedback" to the other knobs when + the waveform of this example. + The class allows a cleaner way to update/"feedback" to the other knobs when one is being changed. Also, this class handles min/max constraints for all the knobs. Idea - knob list - in "set" method, knob object is passed as well From 8cae3977a2ddb4eac099033dc0aade33316cf273 Mon Sep 17 00:00:00 2001 From: Thomas Hisch Date: Sun, 9 Nov 2014 14:29:15 +0100 Subject: [PATCH 02/26] fix multiple whitespace issues in svg_*.py examples (E293, E291) --- examples/user_interfaces/svg_histogram.py | 61 +++++++++--------- examples/user_interfaces/svg_tooltip.py | 75 ++++++++++++----------- 2 files changed, 69 insertions(+), 67 deletions(-) diff --git a/examples/user_interfaces/svg_histogram.py b/examples/user_interfaces/svg_histogram.py index 9e5c3bc74d97..fff0aa873fb2 100755 --- a/examples/user_interfaces/svg_histogram.py +++ b/examples/user_interfaces/svg_histogram.py @@ -3,29 +3,29 @@ """ Demonstrate how to create an interactive histogram, in which bars -are hidden or shown by cliking on legend markers. +are hidden or shown by cliking on legend markers. -The interactivity is encoded in ecmascript (javascript) and inserted in -the SVG code in a post-processing step. To render the image, open it in -a web browser. SVG is supported in most web browsers used by Linux and -OSX users. Windows IE9 supports SVG, but earlier versions do not. +The interactivity is encoded in ecmascript (javascript) and inserted in +the SVG code in a post-processing step. To render the image, open it in +a web browser. SVG is supported in most web browsers used by Linux and +OSX users. Windows IE9 supports SVG, but earlier versions do not. Notes ----- The matplotlib backend lets us assign ids to each object. This is the -mechanism used here to relate matplotlib objects created in python and +mechanism used here to relate matplotlib objects created in python and the corresponding SVG constructs that are parsed in the second step. -While flexible, ids are cumbersome to use for large collection of +While flexible, ids are cumbersome to use for large collection of objects. Two mechanisms could be used to simplify things: * systematic grouping of objects into SVG tags, * assingning classes to each SVG object according to its origin. - -For example, instead of modifying the properties of each individual bar, + +For example, instead of modifying the properties of each individual bar, the bars from the `hist` function could either be grouped in -a PatchCollection, or be assigned a class="hist_##" attribute. +a PatchCollection, or be assigned a class="hist_##" attribute. CSS could also be used more extensively to replace repetitive markup -troughout the generated SVG. +troughout the generated SVG. __author__="david.huard@gmail.com" @@ -40,7 +40,7 @@ plt.rcParams['svg.embed_char_paths'] = 'none' -# Apparently, this `register_namespace` method works only with +# Apparently, this `register_namespace` method works only with # python 2.7 and up and is necessary to avoid garbling the XML name # space with ns0. ET.register_namespace("", "http://www.w3.org/2000/svg") @@ -54,11 +54,11 @@ H = plt.hist([r, r1], label=labels) containers = H[-1] leg = plt.legend(frameon=False) -plt.title("""From a web browser, click on the legend +plt.title("""From a web browser, click on the legend marker to toggle the corresponding histogram.""") -# --- Add ids to the svg objects we'll modify +# --- Add ids to the svg objects we'll modify hist_patches = {} for ic, c in enumerate(containers): @@ -67,7 +67,7 @@ element.set_gid('hist_%d_patch_%d' % (ic, il)) hist_patches['hist_%d' %ic].append('hist_%d_patch_%d' % (ic, il)) -# Set ids for the legend patches +# Set ids for the legend patches for i, t in enumerate(leg.get_patches()): t.set_gid('leg_patch_%d' % i) @@ -85,32 +85,32 @@ # --- Add interactivity --- -# Add attributes to the patch objects. +# Add attributes to the patch objects. for i, t in enumerate(leg.get_patches()): el = xmlid['leg_patch_%d' % i] el.set('cursor', 'pointer') el.set('onclick', "toggle_hist(this)") -# Add attributes to the text objects. +# Add attributes to the text objects. for i, t in enumerate(leg.get_texts()): el = xmlid['leg_text_%d' % i] el.set('cursor', 'pointer') el.set('onclick', "toggle_hist(this)") -# Create script defining the function `toggle_hist`. -# We create a global variable `container` that stores the patches id -# belonging to each histogram. Then a function "toggle_element" sets the +# Create script defining the function `toggle_hist`. +# We create a global variable `container` that stores the patches id +# belonging to each histogram. Then a function "toggle_element" sets the # visibility attribute of all patches of each histogram and the opacity -# of the marker itself. +# of the marker itself. script = """ """ From 2f5b1e17e2d286a39127a8c9586200ce788c02aa Mon Sep 17 00:00:00 2001 From: Thomas Hisch Date: Sun, 9 Nov 2014 15:18:48 +0100 Subject: [PATCH 03/26] pep8 fix E201 --- examples/pylab_examples/table_demo.py | 10 +++++----- examples/pylab_examples/tricontour_demo.py | 18 +++++++++--------- examples/pylab_examples/tripcolor_demo.py | 18 +++++++++--------- examples/pylab_examples/triplot_demo.py | 18 +++++++++--------- .../shapes_and_collections/artist_reference.py | 18 +++++++++--------- 5 files changed, 41 insertions(+), 41 deletions(-) diff --git a/examples/pylab_examples/table_demo.py b/examples/pylab_examples/table_demo.py index 8e80056c347d..fdecf2f0c9e7 100644 --- a/examples/pylab_examples/table_demo.py +++ b/examples/pylab_examples/table_demo.py @@ -5,11 +5,11 @@ import matplotlib.pyplot as plt -data = [[ 66386, 174296, 75131, 577908, 32015], - [ 58230, 381139, 78045, 99308, 160454], - [ 89135, 80552, 152558, 497981, 603535], - [ 78415, 81858, 150656, 193263, 69638], - [ 139361, 331509, 343164, 781380, 52269]] +data = [[66386, 174296, 75131, 577908, 32015], + [58230, 381139, 78045, 99308, 160454], + [89135, 80552, 152558, 497981, 603535], + [78415, 81858, 150656, 193263, 69638], + [139361, 331509, 343164, 781380, 52269]] columns = ('Freeze', 'Wind', 'Flood', 'Quake', 'Hail') rows = ['%d year' % x for x in (100, 50, 20, 10, 5)] diff --git a/examples/pylab_examples/tricontour_demo.py b/examples/pylab_examples/tricontour_demo.py index c0c266c1ce51..c489e60097ae 100644 --- a/examples/pylab_examples/tricontour_demo.py +++ b/examples/pylab_examples/tricontour_demo.py @@ -58,10 +58,10 @@ [-0.052, 1.022], [-0.052, 1.017], [-0.069, 1.010], [-0.064, 1.005], [-0.048, 1.005], [-0.031, 1.005], [-0.031, 0.996], [-0.040, 0.987], [-0.045, 0.980], [-0.052, 0.975], [-0.040, 0.973], [-0.026, 0.968], - [-0.020, 0.954], [-0.006, 0.947], [ 0.003, 0.935], [ 0.006, 0.926], - [ 0.005, 0.921], [ 0.022, 0.923], [ 0.033, 0.912], [ 0.029, 0.905], - [ 0.017, 0.900], [ 0.012, 0.895], [ 0.027, 0.893], [ 0.019, 0.886], - [ 0.001, 0.883], [-0.012, 0.884], [-0.029, 0.883], [-0.038, 0.879], + [-0.020, 0.954], [-0.006, 0.947], [0.003, 0.935], [0.006, 0.926], + [0.005, 0.921], [0.022, 0.923], [0.033, 0.912], [0.029, 0.905], + [0.017, 0.900], [0.012, 0.895], [0.027, 0.893], [0.019, 0.886], + [0.001, 0.883], [-0.012, 0.884], [-0.029, 0.883], [-0.038, 0.879], [-0.057, 0.881], [-0.062, 0.876], [-0.078, 0.876], [-0.087, 0.872], [-0.030, 0.907], [-0.007, 0.905], [-0.057, 0.916], [-0.025, 0.933], [-0.077, 0.990], [-0.059, 0.993]]) @@ -72,11 +72,11 @@ z = np.exp(-0.01*((x-x0)*(x-x0) + (y-y0)*(y-y0))) triangles = np.asarray([ - [67, 66, 1], [65, 2, 66], [ 1, 66, 2], [64, 2, 65], [63, 3, 64], - [60, 59, 57], [ 2, 64, 3], [ 3, 63, 4], [ 0, 67, 1], [62, 4, 63], - [57, 59, 56], [59, 58, 56], [61, 60, 69], [57, 69, 60], [ 4, 62, 68], - [ 6, 5, 9], [61, 68, 62], [69, 68, 61], [ 9, 5, 70], [ 6, 8, 7], - [ 4, 70, 5], [ 8, 6, 9], [56, 69, 57], [69, 56, 52], [70, 10, 9], + [67, 66, 1], [65, 2, 66], [1, 66, 2], [64, 2, 65], [63, 3, 64], + [60, 59, 57], [2, 64, 3], [3, 63, 4], [0, 67, 1], [62, 4, 63], + [57, 59, 56], [59, 58, 56], [61, 60, 69], [57, 69, 60], [4, 62, 68], + [6, 5, 9], [61, 68, 62], [69, 68, 61], [9, 5, 70], [6, 8, 7], + [4, 70, 5], [8, 6, 9], [56, 69, 57], [69, 56, 52], [70, 10, 9], [54, 53, 55], [56, 55, 53], [68, 70, 4], [52, 56, 53], [11, 10, 12], [69, 71, 68], [68, 13, 70], [10, 70, 13], [51, 50, 52], [13, 68, 71], [52, 71, 69], [12, 10, 13], [71, 52, 50], [71, 14, 13], [50, 49, 71], diff --git a/examples/pylab_examples/tripcolor_demo.py b/examples/pylab_examples/tripcolor_demo.py index 9fdb2932311e..1adb239faf83 100644 --- a/examples/pylab_examples/tripcolor_demo.py +++ b/examples/pylab_examples/tripcolor_demo.py @@ -65,10 +65,10 @@ [-0.052, 1.022], [-0.052, 1.017], [-0.069, 1.010], [-0.064, 1.005], [-0.048, 1.005], [-0.031, 1.005], [-0.031, 0.996], [-0.040, 0.987], [-0.045, 0.980], [-0.052, 0.975], [-0.040, 0.973], [-0.026, 0.968], - [-0.020, 0.954], [-0.006, 0.947], [ 0.003, 0.935], [ 0.006, 0.926], - [ 0.005, 0.921], [ 0.022, 0.923], [ 0.033, 0.912], [ 0.029, 0.905], - [ 0.017, 0.900], [ 0.012, 0.895], [ 0.027, 0.893], [ 0.019, 0.886], - [ 0.001, 0.883], [-0.012, 0.884], [-0.029, 0.883], [-0.038, 0.879], + [-0.020, 0.954], [-0.006, 0.947], [0.003, 0.935], [0.006, 0.926], + [0.005, 0.921], [0.022, 0.923], [0.033, 0.912], [0.029, 0.905], + [0.017, 0.900], [0.012, 0.895], [0.027, 0.893], [0.019, 0.886], + [0.001, 0.883], [-0.012, 0.884], [-0.029, 0.883], [-0.038, 0.879], [-0.057, 0.881], [-0.062, 0.876], [-0.078, 0.876], [-0.087, 0.872], [-0.030, 0.907], [-0.007, 0.905], [-0.057, 0.916], [-0.025, 0.933], [-0.077, 0.990], [-0.059, 0.993]]) @@ -76,11 +76,11 @@ y = xy[:, 1]*180/3.14159 triangles = np.asarray([ - [67, 66, 1], [65, 2, 66], [ 1, 66, 2], [64, 2, 65], [63, 3, 64], - [60, 59, 57], [ 2, 64, 3], [ 3, 63, 4], [ 0, 67, 1], [62, 4, 63], - [57, 59, 56], [59, 58, 56], [61, 60, 69], [57, 69, 60], [ 4, 62, 68], - [ 6, 5, 9], [61, 68, 62], [69, 68, 61], [ 9, 5, 70], [ 6, 8, 7], - [ 4, 70, 5], [ 8, 6, 9], [56, 69, 57], [69, 56, 52], [70, 10, 9], + [67, 66, 1], [65, 2, 66], [1, 66, 2], [64, 2, 65], [63, 3, 64], + [60, 59, 57], [2, 64, 3], [3, 63, 4], [0, 67, 1], [62, 4, 63], + [57, 59, 56], [59, 58, 56], [61, 60, 69], [57, 69, 60], [4, 62, 68], + [6, 5, 9], [61, 68, 62], [69, 68, 61], [9, 5, 70], [6, 8, 7], + [4, 70, 5], [8, 6, 9], [56, 69, 57], [69, 56, 52], [70, 10, 9], [54, 53, 55], [56, 55, 53], [68, 70, 4], [52, 56, 53], [11, 10, 12], [69, 71, 68], [68, 13, 70], [10, 70, 13], [51, 50, 52], [13, 68, 71], [52, 71, 69], [12, 10, 13], [71, 52, 50], [71, 14, 13], [50, 49, 71], diff --git a/examples/pylab_examples/triplot_demo.py b/examples/pylab_examples/triplot_demo.py index 84dcb4a76b02..3c030fbac45e 100644 --- a/examples/pylab_examples/triplot_demo.py +++ b/examples/pylab_examples/triplot_demo.py @@ -56,10 +56,10 @@ [-0.052, 1.022], [-0.052, 1.017], [-0.069, 1.010], [-0.064, 1.005], [-0.048, 1.005], [-0.031, 1.005], [-0.031, 0.996], [-0.040, 0.987], [-0.045, 0.980], [-0.052, 0.975], [-0.040, 0.973], [-0.026, 0.968], - [-0.020, 0.954], [-0.006, 0.947], [ 0.003, 0.935], [ 0.006, 0.926], - [ 0.005, 0.921], [ 0.022, 0.923], [ 0.033, 0.912], [ 0.029, 0.905], - [ 0.017, 0.900], [ 0.012, 0.895], [ 0.027, 0.893], [ 0.019, 0.886], - [ 0.001, 0.883], [-0.012, 0.884], [-0.029, 0.883], [-0.038, 0.879], + [-0.020, 0.954], [-0.006, 0.947], [0.003, 0.935], [0.006, 0.926], + [0.005, 0.921], [0.022, 0.923], [0.033, 0.912], [0.029, 0.905], + [0.017, 0.900], [0.012, 0.895], [0.027, 0.893], [0.019, 0.886], + [0.001, 0.883], [-0.012, 0.884], [-0.029, 0.883], [-0.038, 0.879], [-0.057, 0.881], [-0.062, 0.876], [-0.078, 0.876], [-0.087, 0.872], [-0.030, 0.907], [-0.007, 0.905], [-0.057, 0.916], [-0.025, 0.933], [-0.077, 0.990], [-0.059, 0.993]]) @@ -67,11 +67,11 @@ y = xy[:, 1]*180/3.14159 triangles = np.asarray([ - [67, 66, 1], [65, 2, 66], [ 1, 66, 2], [64, 2, 65], [63, 3, 64], - [60, 59, 57], [ 2, 64, 3], [ 3, 63, 4], [ 0, 67, 1], [62, 4, 63], - [57, 59, 56], [59, 58, 56], [61, 60, 69], [57, 69, 60], [ 4, 62, 68], - [ 6, 5, 9], [61, 68, 62], [69, 68, 61], [ 9, 5, 70], [ 6, 8, 7], - [ 4, 70, 5], [ 8, 6, 9], [56, 69, 57], [69, 56, 52], [70, 10, 9], + [67, 66, 1], [65, 2, 66], [1, 66, 2], [64, 2, 65], [63, 3, 64], + [60, 59, 57], [2, 64, 3], [3, 63, 4], [0, 67, 1], [62, 4, 63], + [57, 59, 56], [59, 58, 56], [61, 60, 69], [57, 69, 60], [4, 62, 68], + [6, 5, 9], [61, 68, 62], [69, 68, 61], [9, 5, 70], [6, 8, 7], + [4, 70, 5], [8, 6, 9], [56, 69, 57], [69, 56, 52], [70, 10, 9], [54, 53, 55], [56, 55, 53], [68, 70, 4], [52, 56, 53], [11, 10, 12], [69, 71, 68], [68, 13, 70], [10, 70, 13], [51, 50, 52], [13, 68, 71], [52, 71, 69], [12, 10, 13], [71, 52, 50], [71, 14, 13], [50, 49, 71], diff --git a/examples/shapes_and_collections/artist_reference.py b/examples/shapes_and_collections/artist_reference.py index 87601a8ec7d5..44e023f3c917 100644 --- a/examples/shapes_and_collections/artist_reference.py +++ b/examples/shapes_and_collections/artist_reference.py @@ -62,15 +62,15 @@ def label(xy, text): # add a path patch Path = mpath.Path path_data = [ - (Path.MOVETO, [0.018, -0.11]), - (Path.CURVE4, [-0.031, -0.051]), - (Path.CURVE4, [-0.115, 0.073]), - (Path.CURVE4, [-0.03 , 0.073]), - (Path.LINETO, [-0.011, 0.039]), - (Path.CURVE4, [0.043, 0.121]), - (Path.CURVE4, [0.075, -0.005]), - (Path.CURVE4, [0.035, -0.027]), - (Path.CLOSEPOLY, [0.018, -0.11]) + (Path.MOVETO, [0.018, -0.110]), + (Path.CURVE4, [-0.031, -0.051]), + (Path.CURVE4, [-0.115, 0.073]), + (Path.CURVE4, [-0.030, 0.073]), + (Path.LINETO, [-0.011, 0.039]), + (Path.CURVE4, [0.043, 0.121]), + (Path.CURVE4, [0.075, -0.005]), + (Path.CURVE4, [0.035, -0.027]), + (Path.CLOSEPOLY, [0.018, -0.110]) ] codes, verts = zip(*path_data) path = mpath.Path(verts + grid[6], codes) From cc7fc7fe235d6e7fac3c4919f47c8064892093e1 Mon Sep 17 00:00:00 2001 From: Thomas Hisch Date: Sun, 9 Nov 2014 13:50:15 +0100 Subject: [PATCH 04/26] pep8 fix e2* in examples dir part 1/2 --- .../animation/double_pendulum_animated.py | 12 +++---- examples/animation/simple_3danim.py | 2 +- examples/axes_grid/demo_floating_axes.py | 4 +-- examples/event_handling/data_browser.py | 4 +-- examples/event_handling/idle_and_timeout.py | 2 +- examples/event_handling/path_editor.py | 2 +- examples/event_handling/pick_event_demo.py | 2 +- examples/event_handling/pick_event_demo2.py | 2 +- examples/event_handling/pipong.py | 18 +++++------ examples/event_handling/poly_editor.py | 6 ++-- examples/event_handling/pong_gtk.py | 2 +- examples/event_handling/zoom_window.py | 4 +-- examples/misc/ftface_props.py | 12 +++---- examples/misc/longshort.py | 4 +-- examples/misc/rc_traits.py | 22 ++++++------- examples/misc/rec_groupby_demo.py | 2 +- examples/misc/svg_filter_line.py | 6 ++-- examples/misc/svg_filter_pie.py | 2 +- examples/mplot3d/hist3d_demo.py | 2 +- examples/mplot3d/lorenz_attractor.py | 4 +-- examples/mplot3d/scatter3d_demo.py | 2 +- examples/pylab_examples/alignment_test.py | 8 ++--- examples/pylab_examples/anscombe.py | 2 +- examples/pylab_examples/arrow_demo.py | 32 +++++++++---------- examples/pylab_examples/bar_stacked.py | 2 +- examples/pylab_examples/barchart_demo2.py | 6 ++-- examples/pylab_examples/boxplot_demo2.py | 10 +++--- examples/pylab_examples/boxplot_demo3.py | 2 +- examples/pylab_examples/broken_axis.py | 8 ++--- examples/pylab_examples/broken_barh.py | 2 +- examples/pylab_examples/colours.py | 6 ++-- examples/pylab_examples/contour_demo.py | 2 +- examples/pylab_examples/contour_image.py | 2 +- examples/pylab_examples/demo_agg_filter.py | 24 +++++++------- examples/pylab_examples/demo_bboximage.py | 8 ++--- examples/pylab_examples/demo_ribbon_box.py | 10 +++--- examples/pylab_examples/dolphin.py | 3 +- examples/pylab_examples/ellipse_collection.py | 2 +- examples/pylab_examples/ellipse_rotated.py | 2 +- examples/pylab_examples/equal_aspect_ratio.py | 2 +- examples/pylab_examples/errorbar_limits.py | 10 +++--- examples/pylab_examples/fancyarrow_demo.py | 6 ++-- examples/pylab_examples/fill_spiral.py | 10 +++--- examples/pylab_examples/finance_work2.py | 14 ++++---- examples/pylab_examples/findobj_demo.py | 2 +- examples/pylab_examples/ganged_plots.py | 2 +- .../pylab_examples/ginput_manual_clabel.py | 2 +- examples/pylab_examples/gradient_bar.py | 4 +-- examples/pylab_examples/hexbin_demo2.py | 2 +- examples/pylab_examples/hist2d_demo.py | 2 +- examples/pylab_examples/hist2d_log_demo.py | 2 +- examples/pylab_examples/hyperlinks.py | 2 +- examples/pylab_examples/image_clip_path.py | 2 +- examples/pylab_examples/image_demo.py | 2 +- examples/pylab_examples/image_demo2.py | 2 +- examples/pylab_examples/image_masked.py | 2 +- .../pylab_examples/image_slices_viewer.py | 4 +-- examples/pylab_examples/layer_images.py | 2 +- examples/pylab_examples/line_collection2.py | 2 +- examples/pylab_examples/log_bar.py | 2 +- examples/pylab_examples/log_demo.py | 2 +- examples/pylab_examples/manual_axis.py | 6 ++-- examples/pylab_examples/masked_demo.py | 2 +- examples/pylab_examples/mri_with_eeg.py | 2 +- examples/pylab_examples/multi_image.py | 2 +- examples/pylab_examples/nan_test.py | 2 +- .../pylab_examples/newscalarformatter_demo.py | 16 +++++----- examples/pylab_examples/quiver_demo.py | 8 ++--- examples/widgets/span_selector.py | 2 +- 69 files changed, 184 insertions(+), 183 deletions(-) diff --git a/examples/animation/double_pendulum_animated.py b/examples/animation/double_pendulum_animated.py index 1cb05a2e3dea..ee88fda82ce4 100644 --- a/examples/animation/double_pendulum_animated.py +++ b/examples/animation/double_pendulum_animated.py @@ -19,20 +19,20 @@ def derivs(state, t): dydx = np.zeros_like(state) dydx[0] = state[1] - del_ = state[2]-state[0] - den1 = (M1+M2)*L1 - M2*L1*cos(del_)*cos(del_) + del_ = state[2] - state[0] + den1 = (M1 + M2)*L1 - M2*L1*cos(del_)*cos(del_) dydx[1] = (M2*L1*state[1]*state[1]*sin(del_)*cos(del_) + M2*G*sin(state[2])*cos(del_) + M2*L2*state[3]*state[3]*sin(del_) - - (M1+M2)*G*sin(state[0]))/den1 + - (M1 + M2)*G*sin(state[0]))/den1 dydx[2] = state[3] den2 = (L2/L1)*den1 dydx[3] = (-M2*L2*state[3]*state[3]*sin(del_)*cos(del_) - + (M1+M2)*G*sin(state[0])*cos(del_) - - (M1+M2)*L1*state[1]*state[1]*sin(del_) - - (M1+M2)*G*sin(state[2]))/den2 + + (M1 + M2)*G*sin(state[0])*cos(del_) + - (M1 + M2)*L1*state[1]*state[1]*sin(del_) + - (M1 + M2)*G*sin(state[2]))/den2 return dydx diff --git a/examples/animation/simple_3danim.py b/examples/animation/simple_3danim.py index fcfb822771b4..60f54625d839 100644 --- a/examples/animation/simple_3danim.py +++ b/examples/animation/simple_3danim.py @@ -22,7 +22,7 @@ def Gen_RandLine(length, dims=2): # subtraction by 0.5 is to change the range to [-0.5, 0.5] # to allow a line to move backwards. step = ((np.random.rand(dims) - 0.5) * 0.1) - lineData[:, index] = lineData[:, index-1] + step + lineData[:, index] = lineData[:, index - 1] + step return lineData diff --git a/examples/axes_grid/demo_floating_axes.py b/examples/axes_grid/demo_floating_axes.py index d3dbede0e1ef..20286bc8c446 100644 --- a/examples/axes_grid/demo_floating_axes.py +++ b/examples/axes_grid/demo_floating_axes.py @@ -130,12 +130,12 @@ def setup_axes3(fig, rect): ax2, aux_ax2 = setup_axes2(fig, 132) theta = np.random.rand(10)*.5*np.pi -radius = np.random.rand(10)+1. +radius = np.random.rand(10) + 1. aux_ax2.scatter(theta, radius) ax3, aux_ax3 = setup_axes3(fig, 133) -theta = (8 + np.random.rand(10)*(14-8))*15. # in degrees +theta = (8 + np.random.rand(10)*(14 - 8))*15. # in degrees radius = np.random.rand(10)*14000. aux_ax3.scatter(theta, radius) diff --git a/examples/event_handling/data_browser.py b/examples/event_handling/data_browser.py index 62a71360e732..00fe087b6703 100644 --- a/examples/event_handling/data_browser.py +++ b/examples/event_handling/data_browser.py @@ -23,7 +23,7 @@ def onpress(self, event): else: inc = -1 self.lastind += inc - self.lastind = np.clip(self.lastind, 0, len(xs)-1) + self.lastind = np.clip(self.lastind, 0, len(xs) - 1) self.update() def onpick(self, event): @@ -37,7 +37,7 @@ def onpick(self, event): x = event.mouseevent.xdata y = event.mouseevent.ydata - distances = np.hypot(x-xs[event.ind], y-ys[event.ind]) + distances = np.hypot(x - xs[event.ind], y - ys[event.ind]) indmin = distances.argmin() dataind = event.ind[indmin] diff --git a/examples/event_handling/idle_and_timeout.py b/examples/event_handling/idle_and_timeout.py index 5495e8b26443..4c22d02596c4 100644 --- a/examples/event_handling/idle_and_timeout.py +++ b/examples/event_handling/idle_and_timeout.py @@ -21,7 +21,7 @@ def on_idle(event): on_idle.count += 1 print('idle', on_idle.count) - line1.set_ydata(np.sin(2*np.pi*t*(N-on_idle.count)/float(N))) + line1.set_ydata(np.sin(2*np.pi*t*(N - on_idle.count)/float(N))) event.canvas.draw() # test boolean return removal if on_idle.count == N: diff --git a/examples/event_handling/path_editor.py b/examples/event_handling/path_editor.py index 2a4a0462a5e1..adf983d9def7 100644 --- a/examples/event_handling/path_editor.py +++ b/examples/event_handling/path_editor.py @@ -80,7 +80,7 @@ def get_ind_under_point(self, event): xy = np.asarray(self.pathpatch.get_path().vertices) xyt = self.pathpatch.get_transform().transform(xy) xt, yt = xyt[:, 0], xyt[:, 1] - d = np.sqrt((xt-event.x)**2 + (yt-event.y)**2) + d = np.sqrt((xt - event.x)**2 + (yt - event.y)**2) ind = d.argmin() if d[ind] >= self.epsilon: diff --git a/examples/event_handling/pick_event_demo.py b/examples/event_handling/pick_event_demo.py index 83d3b6ebcaef..63ec45670ed6 100755 --- a/examples/event_handling/pick_event_demo.py +++ b/examples/event_handling/pick_event_demo.py @@ -120,7 +120,7 @@ def line_picker(line, mouseevent): xdata = line.get_xdata() ydata = line.get_ydata() maxd = 0.05 - d = np.sqrt((xdata-mouseevent.xdata)**2. + (ydata-mouseevent.ydata)**2.) + d = np.sqrt((xdata - mouseevent.xdata)**2. + (ydata - mouseevent.ydata)**2.) ind = np.nonzero(np.less_equal(d, maxd)) if len(ind): diff --git a/examples/event_handling/pick_event_demo2.py b/examples/event_handling/pick_event_demo2.py index 3223375a7ca7..167ae33b48fb 100644 --- a/examples/event_handling/pick_event_demo2.py +++ b/examples/event_handling/pick_event_demo2.py @@ -25,7 +25,7 @@ def onpick(event): figi = plt.figure() for subplotnum, dataind in enumerate(event.ind): - ax = figi.add_subplot(N, 1, subplotnum+1) + ax = figi.add_subplot(N, 1, subplotnum + 1) ax.plot(X[dataind]) ax.text(0.05, 0.9, 'mu=%1.3f\nsigma=%1.3f' % (xs[dataind], ys[dataind]), transform=ax.transAxes, va='top') diff --git a/examples/event_handling/pipong.py b/examples/event_handling/pipong.py index 4a403b5e7e5d..ae6b264de2c7 100755 --- a/examples/event_handling/pipong.py +++ b/examples/event_handling/pipong.py @@ -80,17 +80,17 @@ def update(self, pads): self.vy *= 1.2 * pad.signy fudge = .001 # probably cleaner with something like...if not self.field.contains(self.x, self.y): - if self.x < 0+fudge: + if self.x < 0 + fudge: #print("player A loses") pads[1].score += 1; self._reset(pads[0]) return True - if self.x > 7-fudge: + if self.x > 7 - fudge: #print("player B loses") pads[0].score += 1; self._reset(pads[1]) return True - if self.y < -1+fudge or self.y > 1-fudge: + if self.y < -1 + fudge or self.y > 1 - fudge: self.vy *= -1.0 # add some randomness, just to make it interesting self.vy -= (randn()/300.0 + 1/300.0) * np.sign(self.vy) @@ -166,10 +166,10 @@ def draw(self, evt): # show the distractors if self.distract: - self.line.set_ydata(np.sin(self.x+self.cnt/self.res)) - self.line2.set_ydata(np.cos(self.x-self.cnt/self.res)) - self.line3.set_ydata(np.tan(self.x+self.cnt/self.res)) - self.line4.set_ydata(np.tan(self.x-self.cnt/self.res)) + self.line.set_ydata(np.sin(self.x + self.cnt/self.res)) + self.line2.set_ydata(np.cos(self.x - self.cnt/self.res)) + self.line3.set_ydata(np.tan(self.x + self.cnt/self.res)) + self.line4.set_ydata(np.tan(self.x - self.cnt/self.res)) draw_artist(self.line) draw_artist(self.line2) draw_artist(self.line3) @@ -224,7 +224,7 @@ def key_press(self, event): if event.key == 'e': self.pads[0].y += .1 if self.pads[0].y > 1 - .3: - self.pads[0].y = 1-.3 + self.pads[0].y = 1 - .3 if event.key == 'd': self.pads[0].y -= .1 if self.pads[0].y < -1: @@ -233,7 +233,7 @@ def key_press(self, event): if event.key == 'i': self.pads[1].y += .1 if self.pads[1].y > 1 - .3: - self.pads[1].y = 1-.3 + self.pads[1].y = 1 - .3 if event.key == 'k': self.pads[1].y -= .1 if self.pads[1].y < -1: diff --git a/examples/event_handling/poly_editor.py b/examples/event_handling/poly_editor.py index 32061c74f5e8..5a7eed38db06 100644 --- a/examples/event_handling/poly_editor.py +++ b/examples/event_handling/poly_editor.py @@ -70,7 +70,7 @@ def get_ind_under_point(self, event): xy = np.asarray(self.poly.xy) xyt = self.poly.get_transform().transform(xy) xt, yt = xyt[:, 0], xyt[:, 1] - d = np.sqrt((xt-event.x)**2 + (yt-event.y)**2) + d = np.sqrt((xt - event.x)**2 + (yt - event.y)**2) indseq = np.nonzero(np.equal(d, np.amin(d)))[0] ind = indseq[0] @@ -107,9 +107,9 @@ def key_press_callback(self, event): elif event.key == 'i': xys = self.poly.get_transform().transform(self.poly.xy) p = event.x, event.y # display coords - for i in range(len(xys)-1): + for i in range(len(xys) - 1): s0 = xys[i] - s1 = xys[i+1] + s1 = xys[i + 1] d = dist_point_to_segment(p, s0, s1) if d <= self.epsilon: self.poly.xy = np.array( diff --git a/examples/event_handling/pong_gtk.py b/examples/event_handling/pong_gtk.py index d2eafc99763f..7c1a837d2ae4 100755 --- a/examples/event_handling/pong_gtk.py +++ b/examples/event_handling/pong_gtk.py @@ -32,4 +32,4 @@ def start_anim(event): tstart = time.time() plt.grid() # to ensure proper background restore plt.show() -print('FPS:' , animation.cnt/(time.time()-tstart)) +print('FPS:', animation.cnt/(time.time() - tstart)) diff --git a/examples/event_handling/zoom_window.py b/examples/event_handling/zoom_window.py index 427a858c77a6..72952f65f808 100644 --- a/examples/event_handling/zoom_window.py +++ b/examples/event_handling/zoom_window.py @@ -30,8 +30,8 @@ def onpress(event): if event.button != 1: return x, y = event.xdata, event.ydata - axzoom.set_xlim(x-0.1, x+0.1) - axzoom.set_ylim(y-0.1, y+0.1) + axzoom.set_xlim(x - 0.1, x + 0.1) + axzoom.set_ylim(y - 0.1, y + 0.1) figzoom.canvas.draw() figsrc.canvas.mpl_connect('button_press_event', onpress) diff --git a/examples/misc/ftface_props.py b/examples/misc/ftface_props.py index f01310948577..1a821cb531e4 100755 --- a/examples/misc/ftface_props.py +++ b/examples/misc/ftface_props.py @@ -17,12 +17,12 @@ font = ft.FT2Font(fname) -print('Num faces :', font.num_faces) # number of faces in file -print('Num glyphs :', font.num_glyphs) # number of glyphs in the face -print('Family name :', font.family_name) # face family name -print('Syle name :', font.style_name) # face syle name -print('PS name :', font.postscript_name) # the postscript name -print('Num fixed :', font.num_fixed_sizes) # number of embedded bitmap in face +print('Num faces :', font.num_faces) # number of faces in file +print('Num glyphs :', font.num_glyphs) # number of glyphs in the face +print('Family name :', font.family_name) # face family name +print('Syle name :', font.style_name) # face syle name +print('PS name :', font.postscript_name) # the postscript name +print('Num fixed :', font.num_fixed_sizes) # number of embedded bitmap in face # the following are only available if face.scalable if font.scalable: diff --git a/examples/misc/longshort.py b/examples/misc/longshort.py index 9cb2a2a50890..56b121db2cfc 100644 --- a/examples/misc/longshort.py +++ b/examples/misc/longshort.py @@ -34,8 +34,8 @@ # long appl, short goog -g = r.gains1-r.gains2 -tr = (1+g).cumprod() # the total return +g = r.gains1 - r.gains2 +tr = (1 + g).cumprod() # the total return # plot the return fig, ax = plt.subplots() diff --git a/examples/misc/rc_traits.py b/examples/misc/rc_traits.py index b329ec9ce924..32827943ee38 100644 --- a/examples/misc/rc_traits.py +++ b/examples/misc/rc_traits.py @@ -19,17 +19,17 @@ flexible_false_trait = traits.Trait(False, flexible_true_trait) colors = { - 'c' : '#00bfbf', - 'b' : '#0000ff', - 'g' : '#008000', - 'k' : '#000000', - 'm' : '#bf00bf', - 'r' : '#ff0000', - 'w' : '#ffffff', - 'y' : '#bfbf00', - 'gold' : '#FFD700', - 'peachpuff' : '#FFDAB9', - 'navajowhite' : '#FFDEAD', + 'c': '#00bfbf', + 'b': '#0000ff', + 'g': '#008000', + 'k': '#000000', + 'm': '#bf00bf', + 'r': '#ff0000', + 'w': '#ffffff', + 'y': '#bfbf00', + 'gold': '#FFD700', + 'peachpuff': '#FFDAB9', + 'navajowhite': '#FFDEAD', } diff --git a/examples/misc/rec_groupby_demo.py b/examples/misc/rec_groupby_demo.py index d5f23011b05e..06f2a1cca160 100644 --- a/examples/misc/rec_groupby_demo.py +++ b/examples/misc/rec_groupby_demo.py @@ -12,7 +12,7 @@ def daily_return(prices): 'an array of daily returns from price array' g = np.zeros_like(prices) - g[1:] = (prices[1:]-prices[:-1])/prices[:-1] + g[1:] = (prices[1:] - prices[:-1])/prices[:-1] return g diff --git a/examples/misc/svg_filter_line.py b/examples/misc/svg_filter_line.py index 45e825ebb76b..8dd6bf6c0138 100644 --- a/examples/misc/svg_filter_line.py +++ b/examples/misc/svg_filter_line.py @@ -36,7 +36,7 @@ shadow.set_color("0.2") # adjust zorder of the shadow lines so that it is drawn below the # original lines - shadow.set_zorder(l.get_zorder()-0.5) + shadow.set_zorder(l.get_zorder() - 0.5) # offset transform ot = mtransforms.offset_copy(l.get_transform(), fig1, @@ -45,7 +45,7 @@ shadow.set_transform(ot) # set the id for a later use - shadow.set_gid(l.get_label()+"_shadow") + shadow.set_gid(l.get_label() + "_shadow") ax.set_xlim(0., 1.) @@ -77,7 +77,7 @@ for l in [l1, l2]: # pick up the svg element with given id - shadow = xmlid[l.get_label()+"_shadow"] + shadow = xmlid[l.get_label() + "_shadow"] # apply shdow filter shadow.set("filter", 'url(#dropshadow)') diff --git a/examples/misc/svg_filter_pie.py b/examples/misc/svg_filter_pie.py index ffb79e3c8e76..20aa9e15824f 100644 --- a/examples/misc/svg_filter_pie.py +++ b/examples/misc/svg_filter_pie.py @@ -36,7 +36,7 @@ for w in pies[0]: # create shadow patch s = Shadow(w, -0.01, -0.01) - s.set_gid(w.get_gid()+"_shadow") + s.set_gid(w.get_gid() + "_shadow") s.set_zorder(w.get_zorder() - 0.1) ax.add_patch(s) diff --git a/examples/mplot3d/hist3d_demo.py b/examples/mplot3d/hist3d_demo.py index 2a57fdb6ecb7..8137c6400d33 100644 --- a/examples/mplot3d/hist3d_demo.py +++ b/examples/mplot3d/hist3d_demo.py @@ -8,7 +8,7 @@ hist, xedges, yedges = np.histogram2d(x, y, bins=4) elements = (len(xedges) - 1) * (len(yedges) - 1) -xpos, ypos = np.meshgrid(xedges[:-1]+0.25, yedges[:-1]+0.25) +xpos, ypos = np.meshgrid(xedges[:-1] + 0.25, yedges[:-1] + 0.25) xpos = xpos.flatten() ypos = ypos.flatten() diff --git a/examples/mplot3d/lorenz_attractor.py b/examples/mplot3d/lorenz_attractor.py index ec464a896061..5302822d685b 100644 --- a/examples/mplot3d/lorenz_attractor.py +++ b/examples/mplot3d/lorenz_attractor.py @@ -11,7 +11,7 @@ from mpl_toolkits.mplot3d import Axes3D -def lorenz(x, y, z, s=10, r=28, b=2.667) : +def lorenz(x, y, z, s=10, r=28, b=2.667): x_dot = s*(y - x) y_dot = r*x - y - x*z z_dot = x*y - b*z @@ -30,7 +30,7 @@ def lorenz(x, y, z, s=10, r=28, b=2.667) : xs[0], ys[0], zs[0] = (0., 1., 1.05) # Stepping through "time". -for i in range(stepCnt) : +for i in range(stepCnt): # Derivatives of the X, Y, Z state x_dot, y_dot, z_dot = lorenz(xs[i], ys[i], zs[i]) xs[i + 1] = xs[i] + (x_dot * dt) diff --git a/examples/mplot3d/scatter3d_demo.py b/examples/mplot3d/scatter3d_demo.py index 6423786100d7..64d792bd3613 100644 --- a/examples/mplot3d/scatter3d_demo.py +++ b/examples/mplot3d/scatter3d_demo.py @@ -4,7 +4,7 @@ def randrange(n, vmin, vmax): - return (vmax-vmin)*np.random.rand(n) + vmin + return (vmax - vmin)*np.random.rand(n) + vmin fig = plt.figure() ax = fig.add_subplot(111, projection='3d') diff --git a/examples/pylab_examples/alignment_test.py b/examples/pylab_examples/alignment_test.py index 1dd83d5d4f5e..52343b09ebd3 100644 --- a/examples/pylab_examples/alignment_test.py +++ b/examples/pylab_examples/alignment_test.py @@ -48,24 +48,24 @@ verticalalignment='top', transform=ax.transAxes) -ax.text(left, 0.5*(bottom+top), 'right center', +ax.text(left, 0.5*(bottom + top), 'right center', horizontalalignment='right', verticalalignment='center', rotation='vertical', transform=ax.transAxes) -ax.text(left, 0.5*(bottom+top), 'left center', +ax.text(left, 0.5*(bottom + top), 'left center', horizontalalignment='left', verticalalignment='center', rotation='vertical', transform=ax.transAxes) -ax.text(0.5*(left+right), 0.5*(bottom+top), 'middle', +ax.text(0.5*(left + right), 0.5*(bottom + top), 'middle', horizontalalignment='center', verticalalignment='center', transform=ax.transAxes) -ax.text(right, 0.5*(bottom+top), 'centered', +ax.text(right, 0.5*(bottom + top), 'centered', horizontalalignment='center', verticalalignment='center', rotation='vertical', diff --git a/examples/pylab_examples/anscombe.py b/examples/pylab_examples/anscombe.py index 192dcbd0dbbb..b5dd3b316d72 100755 --- a/examples/pylab_examples/anscombe.py +++ b/examples/pylab_examples/anscombe.py @@ -20,7 +20,7 @@ def fit(x): - return 3+0.5*x + return 3 + 0.5*x xfit = array([amin(x), amax(x)]) diff --git a/examples/pylab_examples/arrow_demo.py b/examples/pylab_examples/arrow_demo.py index 7875247a9a0a..b01cfb261d3f 100644 --- a/examples/pylab_examples/arrow_demo.py +++ b/examples/pylab_examples/arrow_demo.py @@ -14,7 +14,7 @@ rates_to_bases = {'r1': 'AT', 'r2': 'TA', 'r3': 'GA', 'r4': 'AG', 'r5': 'CA', 'r6': 'AC', \ 'r7': 'GT', 'r8': 'TG', 'r9': 'CT', 'r10': 'TC', 'r11': 'GC', 'r12': 'CG'} numbered_bases_to_rates = dict([(v, k) for k, v in rates_to_bases.items()]) -lettered_bases_to_rates = dict([(v, 'r'+v) for k, v in rates_to_bases.items()]) +lettered_bases_to_rates = dict([(v, 'r' + v) for k, v in rates_to_bases.items()]) def add_dicts(d1, d2): @@ -127,18 +127,18 @@ def do_fontsize(k): # tuple of x, y for start position positions = {\ - 'AT': (arrow_h_offset, 1+arrow_sep), - 'TA': (1-arrow_h_offset, 1-arrow_sep), + 'AT': (arrow_h_offset, 1 + arrow_sep), + 'TA': (1 - arrow_h_offset, 1 - arrow_sep), 'GA': (-arrow_sep, arrow_h_offset), - 'AG': (arrow_sep, 1-arrow_h_offset), - 'CA': (1-d-r2v, d-r2v), - 'AC': (d+r2v, 1-d+r2v), - 'GT': (d-r2v, d+r2v), - 'TG': (1-d+r2v, 1-d-r2v), - 'CT': (1-arrow_sep, arrow_h_offset), - 'TC': (1+arrow_sep, 1-arrow_h_offset), + 'AG': (arrow_sep, 1 - arrow_h_offset), + 'CA': (1 - d - r2v, d - r2v), + 'AC': (d + r2v, 1 - d + r2v), + 'GT': (d - r2v, d + r2v), + 'TG': (1 - d + r2v, 1 - d - r2v), + 'CT': (1 - arrow_sep, arrow_h_offset), + 'TC': (1 + arrow_sep, 1 - arrow_h_offset), 'GC': (arrow_h_offset, arrow_sep), - 'CG': (1-arrow_h_offset, -arrow_sep), + 'CG': (1 - arrow_h_offset, -arrow_sep), } if normalize_data: @@ -154,8 +154,8 @@ def do_fontsize(k): def draw_arrow(pair, alpha=alpha, ec=ec, labelcolor=labelcolor): # set the length of the arrow if display == 'length': - length = max_head_length+(max_arrow_length-max_head_length) *\ - data[pair]/sf + length = max_head_length + data[pair]/sf*(max_arrow_length - + max_head_length) else: length = max_arrow_length # set the transparency of the arrow @@ -196,8 +196,8 @@ def draw_arrow(pair, alpha=alpha, ec=ec, labelcolor=labelcolor): elif where == 'absolute': orig_position = array([[max_arrow_length/2.0, 3*max_arrow_width]]) elif where == 'right': - orig_position = array([[length-3*max_arrow_width,\ - 3*max_arrow_width]]) + orig_position = array([[length - 3*max_arrow_width, + 3*max_arrow_width]]) elif where == 'center': orig_position = array([[length/2.0, 3*max_arrow_width]]) else: @@ -217,7 +217,7 @@ def draw_arrow(pair, alpha=alpha, ec=ec, labelcolor=labelcolor): # test data all_on_max = dict([(i, 1) for i in 'TCAG'] + \ - [(i+j, 0.6) for i in 'TCAG' for j in 'TCAG']) + [(i + j, 0.6) for i in 'TCAG' for j in 'TCAG']) realistic_data = { 'A': 0.4, diff --git a/examples/pylab_examples/bar_stacked.py b/examples/pylab_examples/bar_stacked.py index 5eef271b159b..d8be34b11926 100644 --- a/examples/pylab_examples/bar_stacked.py +++ b/examples/pylab_examples/bar_stacked.py @@ -18,7 +18,7 @@ plt.ylabel('Scores') plt.title('Scores by group and gender') -plt.xticks(ind+width/2., ('G1', 'G2', 'G3', 'G4', 'G5')) +plt.xticks(ind + width/2., ('G1', 'G2', 'G3', 'G4', 'G5')) plt.yticks(np.arange(0, 81, 10)) plt.legend((p1[0], p2[0]), ('Men', 'Women')) diff --git a/examples/pylab_examples/barchart_demo2.py b/examples/pylab_examples/barchart_demo2.py index 80cef6c209ae..389a3872b985 100644 --- a/examples/pylab_examples/barchart_demo2.py +++ b/examples/pylab_examples/barchart_demo2.py @@ -29,7 +29,7 @@ fig, ax1 = plt.subplots(figsize=(9, 7)) plt.subplots_adjust(left=0.115, right=0.88) fig.canvas.set_window_title('Eldorado K-8 Fitness Chart') -pos = np.arange(numTests)+0.5 # Center bars on the Y-axis ticks +pos = np.arange(numTests) + 0.5 # Center bars on the Y-axis ticks rects = ax1.barh(pos, rankings, align='center', height=0.5, color='m') ax1.axis([0, 100, 0, 5]) @@ -64,7 +64,7 @@ def withnew(i, scr): return scr scoreLabels = [withnew(i, scr) for i, scr in enumerate(scores)] -scoreLabels = [i+j for i, j in zip(scoreLabels, testMeta)] +scoreLabels = [i + j for i, j in zip(scoreLabels, testMeta)] # set the tick locations ax2.set_yticks(pos) # set the tick labels @@ -107,7 +107,7 @@ def withnew(i, scr): align = 'right' # Center the text vertically in the bar - yloc = rect.get_y()+rect.get_height()/2.0 + yloc = rect.get_y() + rect.get_height()/2.0 ax1.text(xloc, yloc, rankStr, horizontalalignment=align, verticalalignment='center', color=clr, weight='bold') diff --git a/examples/pylab_examples/boxplot_demo2.py b/examples/pylab_examples/boxplot_demo2.py index 549fccdc4993..c955a4bd35cd 100644 --- a/examples/pylab_examples/boxplot_demo2.py +++ b/examples/pylab_examples/boxplot_demo2.py @@ -24,7 +24,7 @@ # Generate some random indices that we'll use to resample the original data # arrays. For code brevity, just use the same random indices for each array -bootstrapIndices = np.random.random_integers(0, N-1, N) +bootstrapIndices = np.random.random_integers(0, N - 1, N) normBoot = norm[bootstrapIndices] expoBoot = expo[bootstrapIndices] gumbBoot = gumb[bootstrapIndices] @@ -85,7 +85,7 @@ color='w', marker='*', markeredgecolor='k') # Set the axes ranges and axes labels -ax1.set_xlim(0.5, numBoxes+0.5) +ax1.set_xlim(0.5, numBoxes + 0.5) top = 40 bottom = -5 ax1.set_ylim(bottom, top) @@ -96,17 +96,17 @@ # hard to compare differences in medians across the samples. Add upper # X-axis tick labels with the sample medians to aid in comparison # (just use two decimal places of precision) -pos = np.arange(numBoxes)+1 +pos = np.arange(numBoxes) + 1 upperLabels = [str(np.round(s, 2)) for s in medians] weights = ['bold', 'semibold'] for tick, label in zip(range(numBoxes), ax1.get_xticklabels()): k = tick % 2 - ax1.text(pos[tick], top-(top*0.05), upperLabels[tick], + ax1.text(pos[tick], top - (top*0.05), upperLabels[tick], horizontalalignment='center', size='x-small', weight=weights[k], color=boxColors[k]) # Finally, add a basic legend -plt.figtext(0.80, 0.08, str(N) + ' Random Numbers' , +plt.figtext(0.80, 0.08, str(N) + ' Random Numbers', backgroundcolor=boxColors[0], color='black', weight='roman', size='x-small') plt.figtext(0.80, 0.045, 'IID Bootstrap Resample', diff --git a/examples/pylab_examples/boxplot_demo3.py b/examples/pylab_examples/boxplot_demo3.py index c10f4b5af0e4..ef03bde7256c 100644 --- a/examples/pylab_examples/boxplot_demo3.py +++ b/examples/pylab_examples/boxplot_demo3.py @@ -34,7 +34,7 @@ def fakeBootStrapper(n): conf_intervals = [None, None, CI1, CI2] fig, ax = plt.subplots() -pos = np.array(range(len(treatments)))+1 +pos = np.array(range(len(treatments))) + 1 bp = ax.boxplot(treatments, sym='k+', positions=pos, notch=1, bootstrap=5000, usermedians=medians, diff --git a/examples/pylab_examples/broken_axis.py b/examples/pylab_examples/broken_axis.py index b44951810a23..6619816fcc7e 100644 --- a/examples/pylab_examples/broken_axis.py +++ b/examples/pylab_examples/broken_axis.py @@ -46,12 +46,12 @@ d = .015 # how big to make the diagonal lines in axes coordinates # arguments to pass plot, just so we don't keep repeating them kwargs = dict(transform=ax.transAxes, color='k', clip_on=False) -ax.plot((-d, +d), (-d, +d), **kwargs) # top-left diagonal -ax.plot((1-d, 1+d), (-d, +d), **kwargs) # top-right diagonal +ax.plot((-d, +d), (-d, +d), **kwargs) # top-left diagonal +ax.plot((1 - d, 1 + d), (-d, +d), **kwargs) # top-right diagonal kwargs.update(transform=ax2.transAxes) # switch to the bottom axes -ax2.plot((-d, +d), (1-d, 1+d), **kwargs) # bottom-left diagonal -ax2.plot((1-d, 1+d), (1-d, 1+d), **kwargs) # bottom-right diagonal +ax2.plot((-d, +d), (1 - d, 1 + d), **kwargs) # bottom-left diagonal +ax2.plot((1 - d, 1 + d), (1 - d, 1 + d), **kwargs) # bottom-right diagonal # What's cool about this is that now if we vary the distance between # ax and ax2 via f.subplots_adjust(hspace=...) or plt.subplot_tool(), diff --git a/examples/pylab_examples/broken_barh.py b/examples/pylab_examples/broken_barh.py index c8083e66b12c..5401980d334b 100644 --- a/examples/pylab_examples/broken_barh.py +++ b/examples/pylab_examples/broken_barh.py @@ -4,7 +4,7 @@ import matplotlib.pyplot as plt fig, ax = plt.subplots() -ax.broken_barh([(110, 30), (150, 10)] , (10, 9), facecolors='blue') +ax.broken_barh([(110, 30), (150, 10)], (10, 9), facecolors='blue') ax.broken_barh([(10, 50), (100, 20), (130, 10)], (20, 9), facecolors=('red', 'yellow', 'green')) ax.set_ylim(5, 35) diff --git a/examples/pylab_examples/colours.py b/examples/pylab_examples/colours.py index 9f6adca86e39..4694fa4f09d9 100644 --- a/examples/pylab_examples/colours.py +++ b/examples/pylab_examples/colours.py @@ -27,7 +27,7 @@ def pastel(colour, weight=2.4): # x = (weight - total) / slack x = (weight - total) / slack - rgb = [c + (x * (1.0-c)) for c in rgb] + rgb = [c + (x * (1.0 - c)) for c in rgb] return rgb @@ -45,8 +45,8 @@ def get_colours(n): colours = [] for start in (0, 1): - for x in np.linspace(0, 1, needed[start]+2): + for x in np.linspace(0, 1, needed[start] + 2): colours.append((base[start] * (1.0 - x)) + - (base[start+1] * x)) + (base[start + 1] * x)) return [pastel(c) for c in colours[0:n]] diff --git a/examples/pylab_examples/contour_demo.py b/examples/pylab_examples/contour_demo.py index c7e189ec8072..5e313bfa24be 100755 --- a/examples/pylab_examples/contour_demo.py +++ b/examples/pylab_examples/contour_demo.py @@ -107,7 +107,7 @@ l, b, w, h = plt.gca().get_position().bounds ll, bb, ww, hh = CB.ax.get_position().bounds -CB.ax.set_position([ll, b+0.1*h, ww, h*0.8]) +CB.ax.set_position([ll, b + 0.1*h, ww, h*0.8]) plt.show() diff --git a/examples/pylab_examples/contour_image.py b/examples/pylab_examples/contour_image.py index a4492bba08ef..653a3153f515 100755 --- a/examples/pylab_examples/contour_image.py +++ b/examples/pylab_examples/contour_image.py @@ -35,7 +35,7 @@ subplot(2, 2, 1) cset1 = contourf(X, Y, Z, levels, - cmap=cm.get_cmap(cmap, 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 diff --git a/examples/pylab_examples/demo_agg_filter.py b/examples/pylab_examples/demo_agg_filter.py index c033328e5159..5eefd75c2e9d 100644 --- a/examples/pylab_examples/demo_agg_filter.py +++ b/examples/pylab_examples/demo_agg_filter.py @@ -8,15 +8,15 @@ def smooth1d(x, window_len): # copied from http://www.scipy.org/Cookbook/SignalSmooth - s = np.r_[2*x[0]-x[window_len:1:-1], x, 2*x[-1]-x[-1:-window_len:-1]] + s = np.r_[2*x[0] - x[window_len:1:-1], x, 2*x[-1] - x[-1:-window_len:-1]] w = np.hanning(window_len) y = np.convolve(w/w.sum(), s, mode='same') - return y[window_len-1:-window_len+1] + return y[window_len - 1 : -window_len + 1] def smooth2d(A, sigma=3): - window_len = max(int(sigma), 3)*2+1 + window_len = max(int(sigma), 3)*2 + 1 A1 = np.array([smooth1d(x, window_len) for x in np.asarray(A)]) A2 = np.transpose(A1) A3 = np.array([smooth1d(x, window_len) for x in A2]) @@ -29,7 +29,7 @@ class BaseFilter(object): def prepare_image(self, src_image, dpi, pad): ny, nx, depth = src_image.shape #tgt_image = np.zeros([pad*2+ny, pad*2+nx, depth], dtype="d") - padded_src = np.zeros([pad*2+ny, pad*2+nx, depth], dtype="d") + padded_src = np.zeros([pad*2 + ny, pad*2 + nx, depth], dtype="d") padded_src[pad:-pad, pad:-pad, :] = src_image[:, :, :] return padded_src # , tgt_image @@ -142,7 +142,7 @@ def __init__(self, pixels, color=None): def __call__(self, im, dpi): pad = self.pixels ny, nx, depth = im.shape - new_im = np.empty([pad*2+ny, pad*2+nx, depth], dtype="d") + new_im = np.empty([pad*2 + ny, pad*2 + nx, depth], dtype="d") alpha = new_im[:, :, 3] alpha.fill(0) alpha[pad:-pad, pad:-pad] = im[:, :, -1] @@ -219,7 +219,7 @@ def filtered_text(ax): # Add white glows to improve visibility of labels. white_glows = FilteredArtistList(cl, GrowFilter(3)) ax.add_artist(white_glows) - white_glows.set_zorder(cl[0].get_zorder()-0.1) + white_glows.set_zorder(cl[0].get_zorder() - 0.1) ax.xaxis.set_visible(False) ax.yaxis.set_visible(False) @@ -253,7 +253,7 @@ def drop_shadow_line(ax): # adjust zorder of the shadow lines so that it is drawn below the # original lines - shadow.set_zorder(l.get_zorder()-0.5) + shadow.set_zorder(l.get_zorder() - 0.5) shadow.set_agg_filter(gauss) shadow.set_rasterized(True) # to support mixed-mode renderers @@ -275,15 +275,15 @@ def drop_shadow_patches(ax): rects1 = ax.bar(ind, menMeans, width, color='r', ec="w", lw=2) womenMeans = (25, 32, 34, 20, 25) - rects2 = ax.bar(ind+width+0.1, womenMeans, width, color='y', ec="w", lw=2) + rects2 = ax.bar(ind + width + 0.1, womenMeans, width, color='y', ec="w", lw=2) #gauss = GaussianFilter(1.5, offsets=(1,1), ) gauss = DropShadowFilter(5, offsets=(1, 1), ) - shadow = FilteredArtistList(rects1+rects2, gauss) + shadow = FilteredArtistList(rects1 + rects2, gauss) ax.add_artist(shadow) - shadow.set_zorder(rects1[0].get_zorder()-0.1) + shadow.set_zorder(rects1[0].get_zorder() - 0.1) - ax.set_xlim(ind[0]-0.5, ind[-1]+1.5) + ax.set_xlim(ind[0] - 0.5, ind[-1] + 1.5) ax.set_ylim(0, 40) ax.xaxis.set_visible(False) @@ -306,7 +306,7 @@ def light_filter_pie(ax): gauss = DropShadowFilter(9, offsets=(3, 4), alpha=0.7) shadow = FilteredArtistList(pies[0], gauss) ax.add_artist(shadow) - shadow.set_zorder(pies[0][0].get_zorder()-0.1) + shadow.set_zorder(pies[0][0].get_zorder() - 0.1) if 1: diff --git a/examples/pylab_examples/demo_bboximage.py b/examples/pylab_examples/demo_bboximage.py index e38c9ee2c10d..6744ca9ece6e 100644 --- a/examples/pylab_examples/demo_bboximage.py +++ b/examples/pylab_examples/demo_bboximage.py @@ -34,16 +34,16 @@ nrow = len(maps)//ncol + 1 xpad_fraction = 0.3 - dx = 1./(ncol + xpad_fraction*(ncol-1)) + dx = 1./(ncol + xpad_fraction*(ncol - 1)) ypad_fraction = 0.3 - dy = 1./(nrow + ypad_fraction*(nrow-1)) + dy = 1./(nrow + ypad_fraction*(nrow - 1)) for i, m in enumerate(maps): ix, iy = divmod(i, nrow) #plt.figimage(a, 10, i*10, cmap=plt.get_cmap(m), origin='lower') - bbox0 = Bbox.from_bounds(ix*dx*(1+xpad_fraction), - 1.-iy*dy*(1+ypad_fraction)-dy, + bbox0 = Bbox.from_bounds(ix*dx*(1 + xpad_fraction), + 1. - iy*dy*(1 + ypad_fraction) - dy, dx, dy) bbox = TransformedBbox(bbox0, ax.transAxes) diff --git a/examples/pylab_examples/demo_ribbon_box.py b/examples/pylab_examples/demo_ribbon_box.py index 5435a4211324..9213a769d90a 100644 --- a/examples/pylab_examples/demo_ribbon_box.py +++ b/examples/pylab_examples/demo_ribbon_box.py @@ -24,7 +24,7 @@ def __init__(self, color): self.original_image.dtype) im[:, :, :3] = self.b_and_h[:, :, np.newaxis] - im[:, :, :3] -= self.color[:, :, np.newaxis]*(1.-np.array(rgb)) + im[:, :, :3] -= self.color[:, :, np.newaxis]*(1. - np.array(rgb)) im[:, :, 3] = self.alpha self.im = im @@ -40,8 +40,8 @@ def get_stretched_image(self, stretch_factor): stretched_image[:, :, :] = cut stretched_image[:self.cut_location, :, :] = \ self.im[:self.cut_location, :, :] - stretched_image[-(ny-self.cut_location):, :, :] = \ - self.im[-(ny-self.cut_location):, :, :] + stretched_image[-(ny - self.cut_location):, :, :] = \ + self.im[-(ny - self.cut_location):, :, :] self._cached_im = stretched_image return stretched_image @@ -108,7 +108,7 @@ def draw(self, renderer, *args, **kwargs): ax.xaxis.set_major_formatter(fmt) for year, h, bc in zip(years, heights, box_colors): - bbox0 = Bbox.from_extents(year-0.4, 0., year+0.4, h) + bbox0 = Bbox.from_extents(year - 0.4, 0., year + 0.4, h) bbox = TransformedBbox(bbox0, ax.transData) rb_patch = RibbonBoxImage(bbox, bc, interpolation="bicubic") @@ -127,7 +127,7 @@ def draw(self, renderer, *args, **kwargs): patch_gradient.set_array(gradient) ax.add_artist(patch_gradient) - ax.set_xlim(years[0]-0.5, years[-1]+0.5) + ax.set_xlim(years[0] - 0.5, years[-1] + 0.5) ax.set_ylim(0, 10000) fig.savefig('ribbon_box.png') diff --git a/examples/pylab_examples/dolphin.py b/examples/pylab_examples/dolphin.py index 78dd51afe7c8..90f5764914f2 100644 --- a/examples/pylab_examples/dolphin.py +++ b/examples/pylab_examples/dolphin.py @@ -71,7 +71,8 @@ code = parts[i] path_code, npoints = code_map[code] codes.extend([path_code] * npoints) - vertices.extend([[float(x) for x in y.split(',')] for y in parts[i+1:i+npoints+1]]) + vertices.extend([[float(x) for x in y.split(',')] for y in + parts[i + 1:i + npoints + 1]]) i += npoints + 1 vertices = np.array(vertices, np.float) vertices[:, 1] -= 160 diff --git a/examples/pylab_examples/ellipse_collection.py b/examples/pylab_examples/ellipse_collection.py index 23334ba6b5d9..469e3432125c 100644 --- a/examples/pylab_examples/ellipse_collection.py +++ b/examples/pylab_examples/ellipse_collection.py @@ -22,7 +22,7 @@ units='x', offsets=XY, transOffset=ax.transData) -ec.set_array((X+Y).ravel()) +ec.set_array((X + Y).ravel()) ax.add_collection(ec) ax.autoscale_view() ax.set_xlabel('X') diff --git a/examples/pylab_examples/ellipse_rotated.py b/examples/pylab_examples/ellipse_rotated.py index 9bd9a208c24c..023db0db1bff 100644 --- a/examples/pylab_examples/ellipse_rotated.py +++ b/examples/pylab_examples/ellipse_rotated.py @@ -3,7 +3,7 @@ delta = 45.0 # degrees -angles = arange(0, 360+delta, delta) +angles = arange(0, 360 + delta, delta) ells = [Ellipse((1, 1), 4, 2, a) for a in angles] a = subplot(111, aspect='equal') diff --git a/examples/pylab_examples/equal_aspect_ratio.py b/examples/pylab_examples/equal_aspect_ratio.py index 2496d7c7c136..e2c5dd3056e9 100755 --- a/examples/pylab_examples/equal_aspect_ratio.py +++ b/examples/pylab_examples/equal_aspect_ratio.py @@ -5,7 +5,7 @@ """ from pylab import * -t = arange(0.0, 1.0+0.01, 0.01) +t = arange(0.0, 1.0 + 0.01, 0.01) s = cos(2*2*pi*t) plot(t, s, '-', lw=2) diff --git a/examples/pylab_examples/errorbar_limits.py b/examples/pylab_examples/errorbar_limits.py index 9b59ddabd66e..9e750dda270d 100644 --- a/examples/pylab_examples/errorbar_limits.py +++ b/examples/pylab_examples/errorbar_limits.py @@ -24,15 +24,15 @@ fig = P.figure() x = arange(10.0)/10.0 -y = (x+0.1)**2 +y = (x + 0.1)**2 P.errorbar(x, y, xerr=0.1, xlolims=True) -y = (x+0.1)**3 +y = (x + 0.1)**3 -P.errorbar(x+0.6, y, xerr=0.1, xuplims=upperlimits, xlolims=lowerlimits) +P.errorbar(x + 0.6, y, xerr=0.1, xuplims=upperlimits, xlolims=lowerlimits) -y = (x+0.1)**4 -P.errorbar(x+1.2, y, xerr=0.1, xuplims=True) +y = (x + 0.1)**4 +P.errorbar(x + 1.2, y, xerr=0.1, xuplims=True) P.xlim(-0.2, 2.4) P.ylim(-0.1, 1.3) diff --git a/examples/pylab_examples/fancyarrow_demo.py b/examples/pylab_examples/fancyarrow_demo.py index 6d9b527be93e..06742f7ff824 100644 --- a/examples/pylab_examples/fancyarrow_demo.py +++ b/examples/pylab_examples/fancyarrow_demo.py @@ -4,8 +4,8 @@ styles = mpatches.ArrowStyle.get_styles() ncol = 2 -nrow = (len(styles)+1) // ncol -figheight = (nrow+0.5) +nrow = (len(styles) + 1) // ncol +figheight = (nrow + 0.5) fig1 = plt.figure(1, (4.*ncol/1.5, figheight/1.5)) fontsize = 0.2 * 70 @@ -29,7 +29,7 @@ def to_texstring(s): ax.add_patch(p) ax.annotate(to_texstring(stylename), (x, y), - (x-1.2, y), + (x - 1.2, y), #xycoords="figure fraction", textcoords="figure fraction", ha="right", va="center", size=fontsize, diff --git a/examples/pylab_examples/fill_spiral.py b/examples/pylab_examples/fill_spiral.py index cd5739b93506..ea91671ad69c 100644 --- a/examples/pylab_examples/fill_spiral.py +++ b/examples/pylab_examples/fill_spiral.py @@ -8,13 +8,13 @@ for dt in arange(0, 2*pi, pi/2.0): - x = a*cos(theta+dt)*exp(b*theta) - y = a*sin(theta+dt)*exp(b*theta) + x = a*cos(theta + dt)*exp(b*theta) + y = a*sin(theta + dt)*exp(b*theta) - dt = dt+pi/4.0 + dt = dt + pi/4.0 - x2 = a*cos(theta+dt)*exp(b*theta) - y2 = a*sin(theta+dt)*exp(b*theta) + x2 = a*cos(theta + dt)*exp(b*theta) + y2 = a*sin(theta + dt)*exp(b*theta) xf = concatenate((x, x2[::-1])) yf = concatenate((y, y2[::-1])) diff --git a/examples/pylab_examples/finance_work2.py b/examples/pylab_examples/finance_work2.py index 99b41c7f953f..4e8cc2143e24 100644 --- a/examples/pylab_examples/finance_work2.py +++ b/examples/pylab_examples/finance_work2.py @@ -54,10 +54,10 @@ def relative_strength(prices, n=14): down = -seed[seed < 0].sum()/n rs = up/down rsi = np.zeros_like(prices) - rsi[:n] = 100. - 100./(1.+rs) + rsi[:n] = 100. - 100./(1. + rs) for i in range(n, len(prices)): - delta = deltas[i-1] # cause the diff is 1 shorter + delta = deltas[i - 1] # cause the diff is 1 shorter if delta > 0: upval = delta @@ -66,11 +66,11 @@ def relative_strength(prices, n=14): upval = 0. downval = -delta - up = (up*(n-1) + upval)/n - down = (down*(n-1) + downval)/n + up = (up*(n - 1) + upval)/n + down = (down*(n - 1) + downval)/n rs = up/down - rsi[i] = 100. - 100./(1.+rs) + rsi[i] = 100. - 100./(1. + rs) return rsi @@ -144,7 +144,7 @@ def moving_average_convergence(x, nslow=26, nfast=12): last.open, last.high, last.low, last.close, last.volume*1e-6, - last.close-last.open) + last.close - last.open) t4 = ax2.text(0.3, 0.9, s, transform=ax2.transAxes, fontsize=textsize) props = font_manager.FontProperties(size=10) @@ -168,7 +168,7 @@ def moving_average_convergence(x, nslow=26, nfast=12): ema9 = moving_average(macd, nema, type='exponential') ax3.plot(r.date, macd, color='black', lw=2) ax3.plot(r.date, ema9, color='blue', lw=1) -ax3.fill_between(r.date, macd-ema9, 0, alpha=0.5, facecolor=fillcolor, edgecolor=fillcolor) +ax3.fill_between(r.date, macd - ema9, 0, alpha=0.5, facecolor=fillcolor, edgecolor=fillcolor) ax3.text(0.025, 0.95, 'MACD (%d, %d, %d)' % (nfast, nslow, nema), va='top', diff --git a/examples/pylab_examples/findobj_demo.py b/examples/pylab_examples/findobj_demo.py index c34ee8dad71e..d48cc703a9b2 100644 --- a/examples/pylab_examples/findobj_demo.py +++ b/examples/pylab_examples/findobj_demo.py @@ -11,7 +11,7 @@ d = c[::-1] fig, ax = plt.subplots() -plt.plot(a, c, 'k--', a, d, 'k:', a, c+d, 'k') +plt.plot(a, c, 'k--', a, d, 'k:', a, c + d, 'k') plt.legend(('Model length', 'Data length', 'Total message length'), 'upper center', shadow=True) plt.ylim([-1, 20]) diff --git a/examples/pylab_examples/ganged_plots.py b/examples/pylab_examples/ganged_plots.py index 51f751946c60..22e9fec49e2d 100644 --- a/examples/pylab_examples/ganged_plots.py +++ b/examples/pylab_examples/ganged_plots.py @@ -39,7 +39,7 @@ yticks(arange(-0.9, 1.0, 0.4)) ylim(-1, 1) -xticklabels = ax1.get_xticklabels()+ax2.get_xticklabels() +xticklabels = ax1.get_xticklabels() + ax2.get_xticklabels() setp(xticklabels, visible=False) show() diff --git a/examples/pylab_examples/ginput_manual_clabel.py b/examples/pylab_examples/ginput_manual_clabel.py index cd8b74c19780..7273454ba37f 100755 --- a/examples/pylab_examples/ginput_manual_clabel.py +++ b/examples/pylab_examples/ginput_manual_clabel.py @@ -66,7 +66,7 @@ def tellme(s): def f(x, y, pts): z = np.zeros_like(x) for p in pts: - z = z + 1/(np.sqrt((x-p[0])**2+(y-p[1])**2)) + z = z + 1/(np.sqrt((x - p[0])**2 + (y - p[1])**2)) return 1/z X, Y = np.meshgrid(np.linspace(-1, 1, 51), np.linspace(-1, 1, 51)) diff --git a/examples/pylab_examples/gradient_bar.py b/examples/pylab_examples/gradient_bar.py index 4aa19fb637f2..9b1331591f9c 100644 --- a/examples/pylab_examples/gradient_bar.py +++ b/examples/pylab_examples/gradient_bar.py @@ -6,7 +6,7 @@ def gbar(ax, x, y, width=0.5, bottom=0): X = [[.6, .6], [.7, .7]] for left, top in zip(x, y): - right = left+width + right = left + width ax.imshow(X, interpolation='bicubic', cmap=cm.Blues, extent=(left, right, bottom, top), alpha=1) @@ -22,7 +22,7 @@ def gbar(ax, x, y, width=0.5, bottom=0): extent=(xmin, xmax, ymin, ymax), alpha=1) N = 10 -x = arange(N)+0.25 +x = arange(N) + 0.25 y = rand(N) gbar(ax, x, y, width=0.7) ax.set_aspect('auto') diff --git a/examples/pylab_examples/hexbin_demo2.py b/examples/pylab_examples/hexbin_demo2.py index 44f858bc591f..7bcdf97549e5 100644 --- a/examples/pylab_examples/hexbin_demo2.py +++ b/examples/pylab_examples/hexbin_demo2.py @@ -12,7 +12,7 @@ X, Y = np.meshgrid(x, y) Z1 = mlab.bivariate_normal(X, Y, 1.0, 1.0, 0.0, 0.0) Z2 = mlab.bivariate_normal(X, Y, 1.5, 0.5, 1, 1) -Z = Z2-Z1 # difference of Gaussians +Z = Z2 - Z1 # difference of Gaussians x = X.ravel() y = Y.ravel() diff --git a/examples/pylab_examples/hist2d_demo.py b/examples/pylab_examples/hist2d_demo.py index 8e986820554c..85ef27ad1d2b 100644 --- a/examples/pylab_examples/hist2d_demo.py +++ b/examples/pylab_examples/hist2d_demo.py @@ -1,6 +1,6 @@ from pylab import * x = randn(1000) -y = randn(1000)+5 +y = randn(1000) + 5 # normal distribution center at x=0 and y=5 hist2d(x, y, bins=40) diff --git a/examples/pylab_examples/hist2d_log_demo.py b/examples/pylab_examples/hist2d_log_demo.py index e923ce245d8b..dada02280ab1 100644 --- a/examples/pylab_examples/hist2d_log_demo.py +++ b/examples/pylab_examples/hist2d_log_demo.py @@ -3,7 +3,7 @@ # normal distribution center at x=0 and y=5 x = randn(100000) -y = randn(100000)+5 +y = randn(100000) + 5 hist2d(x, y, bins=40, norm=LogNorm()) colorbar() diff --git a/examples/pylab_examples/hyperlinks.py b/examples/pylab_examples/hyperlinks.py index c19bda075e5b..e8f0b674052b 100644 --- a/examples/pylab_examples/hyperlinks.py +++ b/examples/pylab_examples/hyperlinks.py @@ -23,7 +23,7 @@ X, Y = np.meshgrid(x, y) Z1 = mlab.bivariate_normal(X, Y, 1.0, 1.0, 0.0, 0.0) Z2 = mlab.bivariate_normal(X, Y, 1.5, 0.5, 1, 1) -Z = Z2-Z1 # difference of Gaussians +Z = Z2 - Z1 # difference of Gaussians im = plt.imshow(Z, interpolation='bilinear', cmap=cm.gray, origin='lower', extent=[-3, 3, -3, 3]) diff --git a/examples/pylab_examples/image_clip_path.py b/examples/pylab_examples/image_clip_path.py index 8b40a67b3654..db1478af968d 100755 --- a/examples/pylab_examples/image_clip_path.py +++ b/examples/pylab_examples/image_clip_path.py @@ -11,7 +11,7 @@ X, Y = np.meshgrid(x, y) Z1 = mlab.bivariate_normal(X, Y, 1.0, 1.0, 0.0, 0.0) Z2 = mlab.bivariate_normal(X, Y, 1.5, 0.5, 1, 1) -Z = Z2-Z1 # difference of Gaussians +Z = Z2 - Z1 # difference of Gaussians path = Path([[0, 1], [1, 0], [0, -1], [-1, 0], [0, 1]]) patch = PathPatch(path, facecolor='none') diff --git a/examples/pylab_examples/image_demo.py b/examples/pylab_examples/image_demo.py index c6fc9890fc6c..792a9a8f8373 100644 --- a/examples/pylab_examples/image_demo.py +++ b/examples/pylab_examples/image_demo.py @@ -9,7 +9,7 @@ X, Y = np.meshgrid(x, y) Z1 = mlab.bivariate_normal(X, Y, 1.0, 1.0, 0.0, 0.0) Z2 = mlab.bivariate_normal(X, Y, 1.5, 0.5, 1, 1) -Z = Z2-Z1 # difference of Gaussians +Z = Z2 - Z1 # difference of Gaussians im = plt.imshow(Z, interpolation='bilinear', cmap=cm.RdYlGn, origin='lower', extent=[-3, 3, -3, 3], diff --git a/examples/pylab_examples/image_demo2.py b/examples/pylab_examples/image_demo2.py index 1a902745ad95..1dd6710799cc 100755 --- a/examples/pylab_examples/image_demo2.py +++ b/examples/pylab_examples/image_demo2.py @@ -28,7 +28,7 @@ x = asum(A, 0) subplot(212) bar(arange(w), x) - xlim(0, h-1) + xlim(0, h - 1) ylabel('density') setp(gca(), 'xticklabels', []) diff --git a/examples/pylab_examples/image_masked.py b/examples/pylab_examples/image_masked.py index b44e4cde2c76..0117358c19de 100644 --- a/examples/pylab_examples/image_masked.py +++ b/examples/pylab_examples/image_masked.py @@ -14,7 +14,7 @@ X, Y = meshgrid(x, y) Z1 = bivariate_normal(X, Y, 1.0, 1.0, 0.0, 0.0) Z2 = bivariate_normal(X, Y, 1.5, 0.5, 1, 1) -Z = 10 * (Z2-Z1) # difference of Gaussians +Z = 10*(Z2 - Z1) # difference of Gaussians # Set up a colormap: palette = cm.gray diff --git a/examples/pylab_examples/image_slices_viewer.py b/examples/pylab_examples/image_slices_viewer.py index 433b67655836..cf90e18e100e 100644 --- a/examples/pylab_examples/image_slices_viewer.py +++ b/examples/pylab_examples/image_slices_viewer.py @@ -18,9 +18,9 @@ def __init__(self, ax, X): def onscroll(self, event): print("%s %s" % (event.button, event.step)) if event.button == 'up': - self.ind = numpy.clip(self.ind+1, 0, self.slices-1) + self.ind = numpy.clip(self.ind + 1, 0, self.slices - 1) else: - self.ind = numpy.clip(self.ind-1, 0, self.slices-1) + self.ind = numpy.clip(self.ind - 1, 0, self.slices - 1) self.update() diff --git a/examples/pylab_examples/layer_images.py b/examples/pylab_examples/layer_images.py index b1ee9469c11b..9b34972c1702 100644 --- a/examples/pylab_examples/layer_images.py +++ b/examples/pylab_examples/layer_images.py @@ -7,7 +7,7 @@ def func3(x, y): - return (1 - x/2 + x**5 + y**3)*exp(-x**2-y**2) + return (1 - x/2 + x**5 + y**3)*exp(-(x**2 + y**2)) # make these smaller to increase the resolution dx, dy = 0.05, 0.05 diff --git a/examples/pylab_examples/line_collection2.py b/examples/pylab_examples/line_collection2.py index 61ee3a3ba3d8..36587f13dcd7 100644 --- a/examples/pylab_examples/line_collection2.py +++ b/examples/pylab_examples/line_collection2.py @@ -8,7 +8,7 @@ N = 50 x = arange(N) # Here are many sets of y to plot vs x -ys = [x+i for i in x] +ys = [x + i for i in x] # We need to set the plot limits, they will not autoscale ax = axes() diff --git a/examples/pylab_examples/log_bar.py b/examples/pylab_examples/log_bar.py index 44bfeadf1b91..741a2b2d784d 100644 --- a/examples/pylab_examples/log_bar.py +++ b/examples/pylab_examples/log_bar.py @@ -14,7 +14,7 @@ dimw = w / dim x = pylab.arange(len(data)) -for i in range(len(data[0])) : +for i in range(len(data[0])): y = [d[i] for d in data] b = pylab.bar(x + i * dimw, y, dimw, bottom=0.001) pylab.gca().set_xticks(x + w / 2) diff --git a/examples/pylab_examples/log_demo.py b/examples/pylab_examples/log_demo.py index b5f2a03bb131..bf7372191fc1 100644 --- a/examples/pylab_examples/log_demo.py +++ b/examples/pylab_examples/log_demo.py @@ -30,7 +30,7 @@ x = 10.0**np.linspace(0.0, 2.0, 20) y = x**2.0 -plt.errorbar(x, y, xerr=0.1*x, yerr=5.0+0.75*y) +plt.errorbar(x, y, xerr=0.1*x, yerr=5.0 + 0.75*y) ax.set_ylim(ymin=0.1) ax.set_title('Errorbars go negative') diff --git a/examples/pylab_examples/manual_axis.py b/examples/pylab_examples/manual_axis.py index 21f8518a7477..13f0f0b8a821 100644 --- a/examples/pylab_examples/manual_axis.py +++ b/examples/pylab_examples/manual_axis.py @@ -23,7 +23,7 @@ def make_xaxis(ax, yloc, offset=0.05, **props): tickline.set_clip_on(False) axline.set_clip_on(False) for loc in locs: - ax.text(loc, yloc-offset, '%1.1f' % loc, + ax.text(loc, yloc - offset, '%1.1f' % loc, horizontalalignment='center', verticalalignment='top') @@ -39,14 +39,14 @@ def make_yaxis(ax, xloc=0, offset=0.05, **props): axline.set_clip_on(False) for loc in locs: - ax.text(xloc-offset, loc, '%1.1f' % loc, + ax.text(xloc - offset, loc, '%1.1f' % loc, verticalalignment='center', horizontalalignment='right') props = dict(color='black', linewidth=2, markeredgewidth=2) x = np.arange(200.) -y = np.sin(2*np.pi*x/200.) + np.random.rand(200)-0.5 +y = np.sin(2*np.pi*x/200.) + np.random.rand(200) - 0.5 fig = figure(facecolor='white') ax = fig.add_subplot(111, frame_on=False) ax.axison = False diff --git a/examples/pylab_examples/masked_demo.py b/examples/pylab_examples/masked_demo.py index cdc4652e6c67..82482b8e38c8 100644 --- a/examples/pylab_examples/masked_demo.py +++ b/examples/pylab_examples/masked_demo.py @@ -20,7 +20,7 @@ setp(lines[1], linewidth=2) setp(lines[2], markersize=10) -legend(('No mask', 'Masked if > 0.5', 'Masked if < -0.5') , +legend(('No mask', 'Masked if > 0.5', 'Masked if < -0.5'), loc='upper right') title('Masked line demo') show() diff --git a/examples/pylab_examples/mri_with_eeg.py b/examples/pylab_examples/mri_with_eeg.py index 8b81500da1b0..3a3760853aa0 100755 --- a/examples/pylab_examples/mri_with_eeg.py +++ b/examples/pylab_examples/mri_with_eeg.py @@ -52,7 +52,7 @@ dmax = data.max() dr = (dmax - dmin)*0.7 # Crowd them a bit. y0 = dmin - y1 = (numRows-1) * dr + dmax + y1 = (numRows - 1) * dr + dmax ylim(y0, y1) segs = [] diff --git a/examples/pylab_examples/multi_image.py b/examples/pylab_examples/multi_image.py index 8df0e30c2c8d..c0c771399604 100644 --- a/examples/pylab_examples/multi_image.py +++ b/examples/pylab_examples/multi_image.py @@ -38,7 +38,7 @@ a.set_xticklabels([]) # Make some fake data with a range that varies # somewhat from one plot to the next. - data = ((1+i+j)/10.0)*rand(10, 20)*1e-6 + data = ((1 + i + j)/10.0)*rand(10, 20)*1e-6 dd = ravel(data) # Manually find the min and max of all colors for # use in setting the color scale. diff --git a/examples/pylab_examples/nan_test.py b/examples/pylab_examples/nan_test.py index f3e3fdcd89c6..190235c5766f 100755 --- a/examples/pylab_examples/nan_test.py +++ b/examples/pylab_examples/nan_test.py @@ -5,7 +5,7 @@ from pylab import * import numpy as np -t = arange(0.0, 1.0+0.01, 0.01) +t = arange(0.0, 1.0 + 0.01, 0.01) s = cos(2*2*pi*t) t[41:60] = NaN #t[50:60] = np.inf diff --git a/examples/pylab_examples/newscalarformatter_demo.py b/examples/pylab_examples/newscalarformatter_demo.py index 3887843bb229..c91a938386d9 100644 --- a/examples/pylab_examples/newscalarformatter_demo.py +++ b/examples/pylab_examples/newscalarformatter_demo.py @@ -7,7 +7,7 @@ f = figure(figsize=(6, 6)) f.text(0.5, 0.975, 'The old formatter', horizontalalignment='center', verticalalignment='top') subplot(221) -plot(x*1e5+1e10, x*1e-10+1e-5) +plot(x*1e5 + 1e10, x*1e-10 + 1e-5) gca().xaxis.set_major_formatter(OldScalarFormatter()) gca().yaxis.set_major_formatter(OldScalarFormatter()) subplot(222) @@ -15,7 +15,7 @@ gca().xaxis.set_major_formatter(OldScalarFormatter()) gca().yaxis.set_major_formatter(OldScalarFormatter()) subplot(223) -plot(-x*1e5-1e10, -x*1e-5-1e-10) +plot(-x*1e5 - 1e10, -x*1e-5 - 1e-10) gca().xaxis.set_major_formatter(OldScalarFormatter()) gca().yaxis.set_major_formatter(OldScalarFormatter()) subplot(224) @@ -28,7 +28,7 @@ f.text(0.5, 0.975, 'The new formatter, default settings', horizontalalignment='center', verticalalignment='top') subplot(221) -plot(x*1e5+1e10, x*1e-10+1e-5) +plot(x*1e5 + 1e10, x*1e-10 + 1e-5) gca().xaxis.set_major_formatter(ScalarFormatter()) gca().yaxis.set_major_formatter(ScalarFormatter()) subplot(222) @@ -36,7 +36,7 @@ gca().xaxis.set_major_formatter(ScalarFormatter()) gca().yaxis.set_major_formatter(ScalarFormatter()) subplot(223) -plot(-x*1e5-1e10, -x*1e-5-1e-10) +plot(-x*1e5 - 1e10, -x*1e-5 - 1e-10) gca().xaxis.set_major_formatter(ScalarFormatter()) gca().yaxis.set_major_formatter(ScalarFormatter()) subplot(224) @@ -49,7 +49,7 @@ f.text(0.5, 0.975, 'The new formatter, no numerical offset', horizontalalignment='center', verticalalignment='top') subplot(221) -plot(x*1e5+1e10, x*1e-10+1e-5) +plot(x*1e5 + 1e10, x*1e-10 + 1e-5) gca().xaxis.set_major_formatter(ScalarFormatter(useOffset=False)) gca().yaxis.set_major_formatter(ScalarFormatter(useOffset=False)) subplot(222) @@ -57,7 +57,7 @@ gca().xaxis.set_major_formatter(ScalarFormatter(useOffset=False)) gca().yaxis.set_major_formatter(ScalarFormatter(useOffset=False)) subplot(223) -plot(-x*1e5-1e10, -x*1e-5-1e-10) +plot(-x*1e5 - 1e10, -x*1e-5 - 1e-10) gca().xaxis.set_major_formatter(ScalarFormatter(useOffset=False)) gca().yaxis.set_major_formatter(ScalarFormatter(useOffset=False)) subplot(224) @@ -70,7 +70,7 @@ f.text(0.5, 0.975, 'The new formatter, with mathtext', horizontalalignment='center', verticalalignment='top') subplot(221) -plot(x*1e5+1e10, x*1e-10+1e-5) +plot(x*1e5 + 1e10, x*1e-10 + 1e-5) gca().xaxis.set_major_formatter(ScalarFormatter(useMathText=True)) gca().yaxis.set_major_formatter(ScalarFormatter(useMathText=True)) subplot(222) @@ -78,7 +78,7 @@ gca().xaxis.set_major_formatter(ScalarFormatter(useMathText=True)) gca().yaxis.set_major_formatter(ScalarFormatter(useMathText=True)) subplot(223) -plot(-x*1e5-1e10, -x*1e-5-1e-10) +plot(-x*1e5 - 1e10, -x*1e-5 - 1e-10) gca().xaxis.set_major_formatter(ScalarFormatter(useMathText=True)) gca().yaxis.set_major_formatter(ScalarFormatter(useMathText=True)) subplot(224) diff --git a/examples/pylab_examples/quiver_demo.py b/examples/pylab_examples/quiver_demo.py index 9da3fa39f60e..f0895a5756c1 100644 --- a/examples/pylab_examples/quiver_demo.py +++ b/examples/pylab_examples/quiver_demo.py @@ -21,8 +21,8 @@ qk = quiverkey(Q, 0.5, 0.92, 2, r'$2 \frac{m}{s}$', labelpos='W', fontproperties={'weight': 'bold'}) l, r, b, t = axis() -dx, dy = r-l, t-b -axis([l-0.05*dx, r+0.05*dx, b-0.05*dy, t+0.05*dy]) +dx, dy = r - l, t - b +axis([l - 0.05*dx, r + 0.05*dx, b - 0.05*dy, t + 0.05*dy]) title('Minimal arguments, no kwargs') @@ -75,8 +75,8 @@ qk = quiverkey(Q, 0.5, 0.92, 2, r'$2 \frac{m}{s}$', labelpos='W', fontproperties={'weight': 'bold'}) l, r, b, t = axis() -dx, dy = r-l, t-b -axis([l-0.05*dx, r+0.05*dx, b-0.05*dy, t+0.05*dy]) +dx, dy = r - l, t - b +axis([l - 0.05*dx, r + 0.05*dx, b - 0.05*dy, t + 0.05*dy]) title('Minimal arguments, no kwargs - masked values') diff --git a/examples/widgets/span_selector.py b/examples/widgets/span_selector.py index 3dd4f6f4ad7c..de4152fd7f7e 100644 --- a/examples/widgets/span_selector.py +++ b/examples/widgets/span_selector.py @@ -23,7 +23,7 @@ def onselect(xmin, xmax): indmin, indmax = np.searchsorted(x, (xmin, xmax)) - indmax = min(len(x)-1, indmax) + indmax = min(len(x) - 1, indmax) thisx = x[indmin:indmax] thisy = y[indmin:indmax] From b680680eb6177f84508f299c86574c9114046467 Mon Sep 17 00:00:00 2001 From: Thomas Hisch Date: Sun, 9 Nov 2014 14:13:45 +0100 Subject: [PATCH 05/26] pep8 fix e2* in examples dir part 2/2 Signed-off-by: Thomas Hisch --- .../pylab_examples/scatter_custom_symbol.py | 2 +- examples/pylab_examples/scatter_hist.py | 2 +- examples/pylab_examples/scatter_masked.py | 2 +- examples/pylab_examples/scatter_profile.py | 2 +- examples/pylab_examples/simple_plot_fps.py | 2 +- examples/pylab_examples/stackplot_demo.py | 2 +- examples/pylab_examples/system_monitor.py | 6 ++-- examples/pylab_examples/tex_unicode_demo.py | 4 +-- examples/pylab_examples/tricontour_demo.py | 2 +- .../tricontour_smooth_delaunay.py | 14 ++++---- .../pylab_examples/tricontour_smooth_user.py | 14 ++++---- examples/pylab_examples/trigradient_demo.py | 2 +- examples/pylab_examples/tripcolor_demo.py | 2 +- .../pylab_examples/usetex_baseline_test.py | 4 +-- examples/pylab_examples/usetex_demo.py | 35 +++++++++++-------- .../artist_reference.py | 2 +- examples/showcase/xkcd.py | 2 +- examples/statistics/errorbar_limits.py | 8 ++--- .../multiple_histograms_side_by_side.py | 5 ++- examples/style_sheets/plot_ggplot.py | 4 +-- examples/tests/backend_driver.py | 12 +++---- .../text_demo_fontdict.py | 10 +++--- examples/units/bar_unit_demo.py | 4 +-- examples/units/ellipse_with_units.py | 4 +-- examples/user_interfaces/embedding_in_wx3.py | 6 ++-- examples/user_interfaces/embedding_in_wx5.py | 2 +- examples/user_interfaces/fourier_demo_wx.py | 10 +++--- examples/user_interfaces/interactive.py | 2 +- examples/user_interfaces/mathtext_wx.py | 8 ++--- examples/user_interfaces/svg_histogram.py | 2 +- examples/widgets/cursor.py | 2 +- examples/widgets/menu.py | 10 +++--- 32 files changed, 97 insertions(+), 91 deletions(-) diff --git a/examples/pylab_examples/scatter_custom_symbol.py b/examples/pylab_examples/scatter_custom_symbol.py index d3bec5819b9f..abd2ebc4381c 100644 --- a/examples/pylab_examples/scatter_custom_symbol.py +++ b/examples/pylab_examples/scatter_custom_symbol.py @@ -5,7 +5,7 @@ # unit area ellipse rx, ry = 3., 1. area = rx * ry * pi -theta = arange(0, 2*pi+0.01, 0.1) +theta = arange(0, 2*pi + 0.01, 0.1) verts = list(zip(rx/area*cos(theta), ry/area*sin(theta))) x, y, s, c = rand(4, 30) diff --git a/examples/pylab_examples/scatter_hist.py b/examples/pylab_examples/scatter_hist.py index 16ee2e0d1d2c..a271cf729e61 100644 --- a/examples/pylab_examples/scatter_hist.py +++ b/examples/pylab_examples/scatter_hist.py @@ -11,7 +11,7 @@ # definitions for the axes left, width = 0.1, 0.65 bottom, height = 0.1, 0.65 -bottom_h = left_h = left+width+0.02 +bottom_h = left_h = left + width + 0.02 rect_scatter = [left, bottom, width, height] rect_histx = [left, bottom_h, width, 0.2] diff --git a/examples/pylab_examples/scatter_masked.py b/examples/pylab_examples/scatter_masked.py index 23e47030d59e..a19805319164 100644 --- a/examples/pylab_examples/scatter_masked.py +++ b/examples/pylab_examples/scatter_masked.py @@ -7,7 +7,7 @@ y = 0.9*rand(N) area = pi*(10 * rand(N))**2 # 0 to 10 point radiuses c = sqrt(area) -r = sqrt(x*x+y*y) +r = sqrt(x*x + y*y) area1 = ma.masked_where(r < r0, area) area2 = ma.masked_where(r >= r0, area) scatter(x, y, s=area1, marker='^', c=c, hold='on') diff --git a/examples/pylab_examples/scatter_profile.py b/examples/pylab_examples/scatter_profile.py index e502e62dfa8f..4bf68dbdd76c 100755 --- a/examples/pylab_examples/scatter_profile.py +++ b/examples/pylab_examples/scatter_profile.py @@ -21,4 +21,4 @@ y = 0.9*pylab.rand(N) s = 20*pylab.rand(N) pylab.scatter(x, y, s) - print('%d symbols in %1.2f s' % (N, time.time()-tstart)) + print('%d symbols in %1.2f s' % (N, time.time() - tstart)) diff --git a/examples/pylab_examples/simple_plot_fps.py b/examples/pylab_examples/simple_plot_fps.py index 883c991ebcf3..6ecfd8c53d4a 100755 --- a/examples/pylab_examples/simple_plot_fps.py +++ b/examples/pylab_examples/simple_plot_fps.py @@ -10,7 +10,7 @@ ion() -t = arange(0.0, 1.0+0.001, 0.001) +t = arange(0.0, 1.0 + 0.001, 0.001) s = cos(2*2*pi*t) plot(t, s, '-', lw=2) diff --git a/examples/pylab_examples/stackplot_demo.py b/examples/pylab_examples/stackplot_demo.py index 63eafc15a500..ba5d1d202f9e 100644 --- a/examples/pylab_examples/stackplot_demo.py +++ b/examples/pylab_examples/stackplot_demo.py @@ -1,7 +1,7 @@ import numpy as np from matplotlib import pyplot as plt -fnx = lambda : np.random.randint(5, 50, 10) +fnx = lambda: np.random.randint(5, 50, 10) y = np.row_stack((fnx(), fnx(), fnx())) x = np.arange(10) diff --git a/examples/pylab_examples/system_monitor.py b/examples/pylab_examples/system_monitor.py index 4e335aacf60d..04e46416f7b6 100644 --- a/examples/pylab_examples/system_monitor.py +++ b/examples/pylab_examples/system_monitor.py @@ -6,17 +6,17 @@ def get_memory(): "Simulate a function that returns system memory" - return 100*(0.5+0.5*sin(0.5*pi*time.time())) + return 100*(0.5 + 0.5*sin(0.5*pi*time.time())) def get_cpu(): "Simulate a function that returns cpu usage" - return 100*(0.5+0.5*sin(0.2*pi*(time.time()-0.25))) + return 100*(0.5 + 0.5*sin(0.2*pi*(time.time() - 0.25))) def get_net(): "Simulate a function that returns network bandwidth" - return 100*(0.5+0.5*sin(0.7*pi*(time.time()-0.1))) + return 100*(0.5 + 0.5*sin(0.7*pi*(time.time() - 0.1))) def get_stats(): diff --git a/examples/pylab_examples/tex_unicode_demo.py b/examples/pylab_examples/tex_unicode_demo.py index 3a77676fb822..19f9de7abc4e 100755 --- a/examples/pylab_examples/tex_unicode_demo.py +++ b/examples/pylab_examples/tex_unicode_demo.py @@ -14,8 +14,8 @@ figure(1, figsize=(6, 4)) ax = axes([0.1, 0.1, 0.8, 0.7]) -t = arange(0.0, 1.0+0.01, 0.01) -s = cos(2*2*pi*t)+2 +t = arange(0.0, 1.0 + 0.01, 0.01) +s = cos(2*2*pi*t) + 2 plot(t, s) xlabel(r'\textbf{time (s)}') diff --git a/examples/pylab_examples/tricontour_demo.py b/examples/pylab_examples/tricontour_demo.py index c489e60097ae..ab1e7a2633ba 100644 --- a/examples/pylab_examples/tricontour_demo.py +++ b/examples/pylab_examples/tricontour_demo.py @@ -69,7 +69,7 @@ y = xy[:, 1]*180/3.14159 x0 = -5 y0 = 52 -z = np.exp(-0.01*((x-x0)*(x-x0) + (y-y0)*(y-y0))) +z = np.exp(-0.01*((x - x0)*(x - x0) + (y - y0)*(y - y0))) triangles = np.asarray([ [67, 66, 1], [65, 2, 66], [1, 66, 2], [64, 2, 65], [63, 3, 64], diff --git a/examples/pylab_examples/tricontour_smooth_delaunay.py b/examples/pylab_examples/tricontour_smooth_delaunay.py index 6197297a2069..a155347dcb90 100644 --- a/examples/pylab_examples/tricontour_smooth_delaunay.py +++ b/examples/pylab_examples/tricontour_smooth_delaunay.py @@ -30,14 +30,14 @@ def experiment_res(x, y): """ An analytic function representing experiment results """ x = 2.*x - r1 = np.sqrt((0.5-x)**2 + (0.5-y)**2) - theta1 = np.arctan2(0.5-x, 0.5-y) - r2 = np.sqrt((-x-0.2)**2 + (-y-0.2)**2) - theta2 = np.arctan2(-x-0.2, -y-0.2) - z = (4*(np.exp((r1/10)**2)-1)*30. * np.cos(3*theta1) + - (np.exp((r2/10)**2)-1)*30. * np.cos(5*theta2) + + r1 = np.sqrt((0.5 - x)**2 + (0.5 - y)**2) + theta1 = np.arctan2(0.5 - x, 0.5 - y) + r2 = np.sqrt((-x - 0.2)**2 + (-y - 0.2)**2) + theta2 = np.arctan2(-x - 0.2, -y - 0.2) + z = (4*(np.exp((r1/10)**2) - 1)*30. * np.cos(3*theta1) + + (np.exp((r2/10)**2) - 1)*30. * np.cos(5*theta2) + 2*(x**2 + y**2)) - return (np.max(z)-z)/(np.max(z)-np.min(z)) + return (np.max(z) - z)/(np.max(z) - np.min(z)) #----------------------------------------------------------------------------- # Generating the initial data test points and triangulation for the demo diff --git a/examples/pylab_examples/tricontour_smooth_user.py b/examples/pylab_examples/tricontour_smooth_user.py index c687ab6ac6db..f5eed105f1f5 100644 --- a/examples/pylab_examples/tricontour_smooth_user.py +++ b/examples/pylab_examples/tricontour_smooth_user.py @@ -14,14 +14,14 @@ #----------------------------------------------------------------------------- def function_z(x, y): """ A function of 2 variables """ - r1 = np.sqrt((0.5-x)**2 + (0.5-y)**2) - theta1 = np.arctan2(0.5-x, 0.5-y) - r2 = np.sqrt((-x-0.2)**2 + (-y-0.2)**2) - theta2 = np.arctan2(-x-0.2, -y-0.2) - z = -(2*(np.exp((r1/10)**2)-1)*30. * np.cos(7.*theta1) + - (np.exp((r2/10)**2)-1)*30. * np.cos(11.*theta2) + + r1 = np.sqrt((0.5 - x)**2 + (0.5 - y)**2) + theta1 = np.arctan2(0.5 - x, 0.5 - y) + r2 = np.sqrt((-x - 0.2)**2 + (-y - 0.2)**2) + theta2 = np.arctan2(-x - 0.2, -y - 0.2) + z = -(2*(np.exp((r1/10)**2) - 1)*30. * np.cos(7.*theta1) + + (np.exp((r2/10)**2) - 1)*30. * np.cos(11.*theta2) + 0.7*(x**2 + y**2)) - return (np.max(z)-z)/(np.max(z)-np.min(z)) + return (np.max(z) - z)/(np.max(z) - np.min(z)) #----------------------------------------------------------------------------- # Creating a Triangulation diff --git a/examples/pylab_examples/trigradient_demo.py b/examples/pylab_examples/trigradient_demo.py index c8967b5397be..6114b8493de5 100644 --- a/examples/pylab_examples/trigradient_demo.py +++ b/examples/pylab_examples/trigradient_demo.py @@ -17,7 +17,7 @@ def dipole_potential(x, y): r_sq = x**2 + y**2 theta = np.arctan2(y, x) z = np.cos(theta)/r_sq - return (np.max(z)-z) / (np.max(z)-np.min(z)) + return (np.max(z) - z) / (np.max(z) - np.min(z)) #----------------------------------------------------------------------------- diff --git a/examples/pylab_examples/tripcolor_demo.py b/examples/pylab_examples/tripcolor_demo.py index 1adb239faf83..d75e6d3ad8f5 100644 --- a/examples/pylab_examples/tripcolor_demo.py +++ b/examples/pylab_examples/tripcolor_demo.py @@ -97,7 +97,7 @@ ymid = y[triangles].mean(axis=1) x0 = -5 y0 = 52 -zfaces = np.exp(-0.01*((xmid-x0)*(xmid-x0) + (ymid-y0)*(ymid-y0))) +zfaces = np.exp(-0.01*((xmid - x0)*(xmid - x0) + (ymid - y0)*(ymid - y0))) # Rather than create a Triangulation object, can simply pass x, y and triangles # arrays to tripcolor directly. It would be better to use a Triangulation diff --git a/examples/pylab_examples/usetex_baseline_test.py b/examples/pylab_examples/usetex_baseline_test.py index f6704e534003..55833c8058b3 100644 --- a/examples/pylab_examples/usetex_baseline_test.py +++ b/examples/pylab_examples/usetex_baseline_test.py @@ -53,7 +53,7 @@ def test_window_extent(ax, usetex, preview): for i, s in enumerate(test_strings): ax.axhline(i, color="r") - ax.text(0., 3-i, s, **text_kw) + ax.text(0., 3 - i, s, **text_kw) ax.set_xlim(-0.1, 1.1) ax.set_ylim(-.8, 3.9) @@ -66,7 +66,7 @@ def test_window_extent(ax, usetex, preview): for i, usetex, preview in [[0, False, False], [1, True, False], [2, True, True]]: - ax = Subplot(F, 1, 3, i+1, usetex=usetex, preview=preview) + ax = Subplot(F, 1, 3, i + 1, usetex=usetex, preview=preview) F.add_subplot(ax) F.subplots_adjust(top=0.85) diff --git a/examples/pylab_examples/usetex_demo.py b/examples/pylab_examples/usetex_demo.py index ff1101043536..c271d46d7edc 100644 --- a/examples/pylab_examples/usetex_demo.py +++ b/examples/pylab_examples/usetex_demo.py @@ -6,11 +6,11 @@ # interface tracking profiles N = 500 delta = 0.6 -X = -1 + 2. * np.arange(N) / (N - 1) -pylab.plot(X, (1 - np.tanh(4.*X/delta))/2, # phase field tanh profiles - X, (X + 1)/2, # level set distance function - X, (1.4 + np.tanh(4.*X/delta))/4, # composition profile - X, X < 0, 'k--', # sharp interface +X = np.linspace(-1, 1, N) +pylab.plot(X, (1 - np.tanh(4.*X/delta))/2, # phase field tanh profiles + X, (X + 1)/2, # level set distance function + X, (1.4 + np.tanh(4.*X/delta))/4, # composition profile + X, X < 0, 'k--', # sharp interface linewidth=5) ## legend @@ -30,31 +30,38 @@ pylab.plot((-delta / 2, -delta / 2 + offset * 2), (height, height + offset), 'k', linewidth=2) pylab.plot((delta / 2, delta / 2 - offset * 2), (height, height - offset), 'k', linewidth=2) pylab.plot((delta / 2, delta / 2 - offset * 2), (height, height + offset), 'k', linewidth=2) -pylab.text(-0.06, height - 0.06, r'$\delta$', {'color' : 'k', 'fontsize' : 24}) +pylab.text(-0.06, height - 0.06, r'$\delta$', {'color': 'k', 'fontsize': 24}) # X-axis label pylab.xticks((-1, 0, 1), ('-1', '0', '1'), color='k', size=20) # Left Y-axis labels -pylab.ylabel(r'\bf{phase field} $\phi$', {'color' : 'b', - 'fontsize' : 20}) +pylab.ylabel(r'\bf{phase field} $\phi$', {'color': 'b', + 'fontsize': 20}) pylab.yticks((0, 0.5, 1), ('0', '.5', '1'), color='k', size=20) # Right Y-axis labels -pylab.text(1.05, 0.5, r"\bf{level set} $\phi$", {'color' : 'g', 'fontsize' : 20}, +pylab.text(1.05, 0.5, r"\bf{level set} $\phi$", {'color': 'g', 'fontsize': 20}, horizontalalignment='left', verticalalignment='center', rotation=90, clip_on=False) -pylab.text(1.01, -0.02, "-1", {'color' : 'k', 'fontsize' : 20}) -pylab.text(1.01, 0.98, "1", {'color' : 'k', 'fontsize' : 20}) -pylab.text(1.01, 0.48, "0", {'color' : 'k', 'fontsize' : 20}) +pylab.text(1.01, -0.02, "-1", {'color': 'k', 'fontsize': 20}) +pylab.text(1.01, 0.98, "1", {'color': 'k', 'fontsize': 20}) +pylab.text(1.01, 0.48, "0", {'color': 'k', 'fontsize': 20}) # level set equations -pylab.text(0.1, 0.85, r'$|\nabla\phi| = 1,$ \newline $ \frac{\partial \phi}{\partial t} + U|\nabla \phi| = 0$', {'color' : 'g', 'fontsize' : 20}) +pylab.text(0.1, 0.85, + r'$|\nabla\phi| = 1,$ \newline $ \frac{\partial \phi}{\partial t}' + r'+ U|\nabla \phi| = 0$', + {'color': 'g', 'fontsize': 20}) # phase field equations -pylab.text(0.2, 0.15, r'$\mathcal{F} = \int f\left( \phi, c \right) dV,$ \newline $ \frac{ \partial \phi } { \partial t } = -M_{ \phi } \frac{ \delta \mathcal{F} } { \delta \phi }$', {'color' : 'b', 'fontsize' : 20}) +pylab.text(0.2, 0.15, + r'$\mathcal{F} = \int f\left( \phi, c \right) dV,$ \newline ' + r'$ \frac{ \partial \phi } { \partial t } = -M_{ \phi } ' + r'\frac{ \delta \mathcal{F} } { \delta \phi }$', + {'color': 'b', 'fontsize': 20}) # these went wrong in pdf in a previous version pylab.text(-.9, .42, r'gamma: $\gamma$', {'color': 'r', 'fontsize': 20}) diff --git a/examples/shapes_and_collections/artist_reference.py b/examples/shapes_and_collections/artist_reference.py index 44e023f3c917..1af2cd6c78e9 100644 --- a/examples/shapes_and_collections/artist_reference.py +++ b/examples/shapes_and_collections/artist_reference.py @@ -55,7 +55,7 @@ def label(xy, text): label(grid[4], "Ellipse") # add an arrow -arrow = mpatches.Arrow(grid[5, 0]-0.05, grid[5, 1]-0.05, 0.1, 0.1, width=0.1) +arrow = mpatches.Arrow(grid[5, 0] - 0.05, grid[5, 1] - 0.05, 0.1, 0.1, width=0.1) patches.append(arrow) label(grid[5], "Arrow") diff --git a/examples/showcase/xkcd.py b/examples/showcase/xkcd.py index 5c731c5a1dd2..517a2e7c1afa 100644 --- a/examples/showcase/xkcd.py +++ b/examples/showcase/xkcd.py @@ -34,7 +34,7 @@ fig = plt.figure() ax = fig.add_axes((0.1, 0.2, 0.8, 0.7)) - ax.bar([-0.125, 1.0-0.125], [0, 100], 0.25) + ax.bar([-0.125, 1.0 - 0.125], [0, 100], 0.25) ax.spines['right'].set_color('none') ax.spines['top'].set_color('none') ax.xaxis.set_ticks_position('bottom') diff --git a/examples/statistics/errorbar_limits.py b/examples/statistics/errorbar_limits.py index f09f71517e79..502637d611fa 100644 --- a/examples/statistics/errorbar_limits.py +++ b/examples/statistics/errorbar_limits.py @@ -20,17 +20,17 @@ # including upper limits uplims = np.zeros(x.shape) uplims[[1, 5, 9]] = True -plt.errorbar(x, y+0.5, xerr=xerr, yerr=yerr, uplims=uplims, ls=ls, +plt.errorbar(x, y + 0.5, xerr=xerr, yerr=yerr, uplims=uplims, ls=ls, color='green') # including lower limits lolims = np.zeros(x.shape) lolims[[2, 4, 8]] = True -plt.errorbar(x, y+1.0, xerr=xerr, yerr=yerr, lolims=lolims, ls=ls, +plt.errorbar(x, y + 1.0, xerr=xerr, yerr=yerr, lolims=lolims, ls=ls, color='red') # including upper and lower limits -plt.errorbar(x, y+1.5, marker='o', ms=8, xerr=xerr, yerr=yerr, +plt.errorbar(x, y + 1.5, marker='o', ms=8, xerr=xerr, yerr=yerr, lolims=lolims, uplims=uplims, ls=ls, color='magenta') # including xlower and xupper limits @@ -43,7 +43,7 @@ uplims = np.zeros(x.shape) lolims[[6]] = True uplims[[3]] = True -plt.errorbar(x, y+2.1, marker='o', ms=8, xerr=xerr, yerr=yerr, +plt.errorbar(x, y + 2.1, marker='o', ms=8, xerr=xerr, yerr=yerr, xlolims=xlolims, xuplims=xuplims, uplims=uplims, lolims=lolims, ls='none', mec='blue', capsize=0, color='cyan') diff --git a/examples/statistics/multiple_histograms_side_by_side.py b/examples/statistics/multiple_histograms_side_by_side.py index 27d36de4b638..370ad08eec4d 100644 --- a/examples/statistics/multiple_histograms_side_by_side.py +++ b/examples/statistics/multiple_histograms_side_by_side.py @@ -23,8 +23,8 @@ x_locations = np.arange(0, sum(binned_maximums), np.max(binned_maximums)) # The bin_edges are the same for all of the histograms -bin_edges = np.linspace(hist_range[0], hist_range[1], number_of_bins+1) -centers = .5 * (bin_edges + np.roll(bin_edges, 1))[:-1] +bin_edges = np.linspace(hist_range[0], hist_range[1], number_of_bins + 1) +centers = .5 * (bin_edges + np.roll(bin_edges, 1))[:-1] heights = np.diff(bin_edges) # Cycle through and plot each histogram @@ -40,4 +40,3 @@ ax.set_xlabel("Data sets") plt.show() - diff --git a/examples/style_sheets/plot_ggplot.py b/examples/style_sheets/plot_ggplot.py index 0542ea35b2bf..2fff1aac9058 100644 --- a/examples/style_sheets/plot_ggplot.py +++ b/examples/style_sheets/plot_ggplot.py @@ -36,8 +36,8 @@ 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.set_xticks(x+width) +ax3.bar(x + width, y2, width, color=plt.rcParams['axes.color_cycle'][2]) +ax3.set_xticks(x + width) ax3.set_xticklabels(['a', 'b', 'c', 'd', 'e']) # circles with colors from default color cycle diff --git a/examples/tests/backend_driver.py b/examples/tests/backend_driver.py index 1de649051c28..46839e0095ad 100755 --- a/examples/tests/backend_driver.py +++ b/examples/tests/backend_driver.py @@ -313,8 +313,8 @@ # examples that generate multiple figures excluded = { - 'pylab' : ['__init__.py', 'toggle_images.py', ], - 'units' : ['__init__.py', 'date_support.py', ], + 'pylab': ['__init__.py', 'toggle_images.py', ], + 'units': ['__init__.py', 'date_support.py', ], } @@ -327,7 +327,7 @@ def report_missing(dir, flist): exclude = set(excluded.get(dir, [])) flist = set(flist) - missing = list(pyfiles-flist-exclude) + missing = list(pyfiles - flist - exclude) missing.sort() if missing: print('%s files not tested: %s' % (dir, ', '.join(missing))) @@ -403,7 +403,7 @@ def drive(backend, directories, python=['python'], switches=[]): future_imports = future_imports + ', unicode_literals' tmpfile.writelines(( - future_imports+'\n', + future_imports + '\n', 'import sys\n', 'sys.path.append("%s")\n' % fpath.replace('\\', '\\\\'), 'import matplotlib\n', @@ -518,7 +518,7 @@ def parse_options(): failures[backend] = \ drive(backend, options.dirs, python, options.switches) t1 = time.time() - times[backend] = (t1-t0)/60.0 + times[backend] = (t1 - t0)/60.0 #print(times) for backend, elapsed in times.items(): @@ -528,4 +528,4 @@ def parse_options(): print(' Failures: %s' % failed) if 'template' in times: print('\ttemplate ratio %1.3f, template residual %1.3f' % ( - elapsed/times['template'], elapsed-times['template'])) + elapsed/times['template'], elapsed - times['template'])) diff --git a/examples/text_labels_and_annotations/text_demo_fontdict.py b/examples/text_labels_and_annotations/text_demo_fontdict.py index a0dcf3f48d3a..ae35d222b8d3 100644 --- a/examples/text_labels_and_annotations/text_demo_fontdict.py +++ b/examples/text_labels_and_annotations/text_demo_fontdict.py @@ -5,14 +5,14 @@ import matplotlib.pyplot as plt -font = {'family' : 'serif', - 'color' : 'darkred', - 'weight' : 'normal', - 'size' : 16, +font = {'family': 'serif', + 'color': 'darkred', + 'weight': 'normal', + 'size': 16, } x = np.linspace(0.0, 5.0, 100) -y = np.cos(2 * np.pi * x) * np.exp(-x) +y = np.cos(2*np.pi*x) * np.exp(-x) plt.plot(x, y, 'k') plt.title('Damped exponential decay', fontdict=font) diff --git a/examples/units/bar_unit_demo.py b/examples/units/bar_unit_demo.py index 33ab24eb6709..76b639e1939a 100644 --- a/examples/units/bar_unit_demo.py +++ b/examples/units/bar_unit_demo.py @@ -17,10 +17,10 @@ womenMeans = (145*cm, 149*cm, 172*cm, 165*cm, 200*cm) womenStd = (30*cm, 25*cm, 20*cm, 31*cm, 22*cm) -p2 = ax.bar(ind+width, womenMeans, width, color='y', bottom=0*cm, yerr=womenStd) +p2 = ax.bar(ind + width, womenMeans, width, color='y', bottom=0*cm, yerr=womenStd) ax.set_title('Scores by group and gender') -ax.set_xticks(ind+width) +ax.set_xticks(ind + width) ax.set_xticklabels(('G1', 'G2', 'G3', 'G4', 'G5')) ax.legend((p1[0], p2[0]), ('Men', 'Women')) diff --git a/examples/units/ellipse_with_units.py b/examples/units/ellipse_with_units.py index ab522b92ac00..42f2e3d6fcb4 100644 --- a/examples/units/ellipse_with_units.py +++ b/examples/units/ellipse_with_units.py @@ -18,8 +18,8 @@ rtheta = angle*np.pi/180. R = np.array([ - [np.cos(rtheta), -np.sin(rtheta)], - [np.sin(rtheta), np.cos(rtheta)], + [np.cos(rtheta), -np.sin(rtheta)], + [np.sin(rtheta), np.cos(rtheta)], ]) diff --git a/examples/user_interfaces/embedding_in_wx3.py b/examples/user_interfaces/embedding_in_wx3.py index b2ddc52551b2..637c96f9324c 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): zmax = np.amax(z) - ERR_TOL ymax_i, xmax_i = np.nonzero(z >= zmax) if self.im.origin == 'upper': - ymax_i = z.shape[0]-ymax_i + ymax_i = z.shape[0] - ymax_i self.lines = a.plot(xmax_i, ymax_i, 'ko') self.toolbar.update() # Not sure why this is needed - ADS @@ -93,7 +93,7 @@ def OnWhiz(self, evt): zmax = np.amax(z) - ERR_TOL ymax_i, xmax_i = np.nonzero(z >= zmax) if self.im.origin == 'upper': - ymax_i = z.shape[0]-ymax_i + ymax_i = z.shape[0] - ymax_i self.lines[0].set_data(xmax_i, ymax_i) self.canvas.draw() @@ -154,7 +154,7 @@ def OnInit(self): def OnBang(self, event): bang_count = xrc.XRCCTRL(self.frame, "bang_count") bangs = bang_count.GetValue() - bangs = int(bangs)+1 + bangs = int(bangs) + 1 bang_count.SetValue(str(bangs)) if __name__ == '__main__': diff --git a/examples/user_interfaces/embedding_in_wx5.py b/examples/user_interfaces/embedding_in_wx5.py index de86805ac0ed..7b8efb31aa86 100644 --- a/examples/user_interfaces/embedding_in_wx5.py +++ b/examples/user_interfaces/embedding_in_wx5.py @@ -19,7 +19,7 @@ def __init__(self, parent, id=-1, dpi=None, **kwargs): sizer = wx.BoxSizer(wx.VERTICAL) sizer.Add(self.canvas, 1, wx.EXPAND) - sizer.Add(self.toolbar, 0 , wx.LEFT | wx.EXPAND) + sizer.Add(self.toolbar, 0, wx.LEFT | wx.EXPAND) self.SetSizer(sizer) diff --git a/examples/user_interfaces/fourier_demo_wx.py b/examples/user_interfaces/fourier_demo_wx.py index e5652b805727..efaaed3152bc 100644 --- a/examples/user_interfaces/fourier_demo_wx.py +++ b/examples/user_interfaces/fourier_demo_wx.py @@ -155,12 +155,12 @@ def mouseMotion(self, evt): if x is None: # outside the axes return x0, y0, f0Init, AInit = self.mouseInfo - self.A.set(AInit+(AInit*(y-y0)/y0), self) + self.A.set(AInit + (AInit*(y - y0)/y0), self) if self.state == 'frequency': - self.f0.set(f0Init+(f0Init*(x-x0)/x0)) + self.f0.set(f0Init + (f0Init*(x - x0)/x0)) elif self.state == 'time': - if (x-x0)/x0 != -1.: - self.f0.set(1./(1./f0Init+(1./f0Init*(x-x0)/x0))) + if (x - x0)/x0 != -1.: + self.f0.set(1./(1./f0Init + (1./f0Init*(x - x0)/x0))) def mouseUp(self, evt): self.state = '' @@ -192,7 +192,7 @@ def compute(self, f0, A): f = np.arange(-6., 6., 0.02) t = np.arange(-2., 2., 0.01) x = A*np.cos(2*np.pi*f0*t)*np.exp(-np.pi*t**2) - X = A/2*(np.exp(-np.pi*(f-f0)**2) + np.exp(-np.pi*(f+f0)**2)) + X = A/2*(np.exp(-np.pi*(f - f0)**2) + np.exp(-np.pi*(f + f0)**2)) return f, X, t, x def repaint(self): diff --git a/examples/user_interfaces/interactive.py b/examples/user_interfaces/interactive.py index 876381ec408c..7c8873f652e5 100755 --- a/examples/user_interfaces/interactive.py +++ b/examples/user_interfaces/interactive.py @@ -238,7 +238,7 @@ def pre_interact(self): # Quick sys.argv hack to extract the option and leave filenames in sys.argv. # For real option handling, use optparse or getopt. if len(sys.argv) > 1 and sys.argv[1] == '-pylab': - sys.argv = [sys.argv[0]]+sys.argv[2:] + sys.argv = [sys.argv[0]] + sys.argv[2:] MatplotLibInterpreter().mainloop() else: GTKInterpreter().mainloop() diff --git a/examples/user_interfaces/mathtext_wx.py b/examples/user_interfaces/mathtext_wx.py index b1f91ceb3365..e6956b7235c2 100644 --- a/examples/user_interfaces/mathtext_wx.py +++ b/examples/user_interfaces/mathtext_wx.py @@ -30,10 +30,10 @@ def mathtext_to_wxbitmap(s): ############################################################ functions = [ - (r'$\sin(2 \pi x)$' , lambda x: sin(2*pi*x)), - (r'$\frac{4}{3}\pi x^3$' , lambda x: (4.0 / 3.0) * pi * x**3), - (r'$\cos(2 \pi x)$' , lambda x: cos(2*pi*x)), - (r'$\log(x)$' , lambda x: log(x)) + (r'$\sin(2 \pi x)$', lambda x: sin(2*pi*x)), + (r'$\frac{4}{3}\pi x^3$', lambda x: (4.0 / 3.0) * pi * x**3), + (r'$\cos(2 \pi x)$', lambda x: cos(2*pi*x)), + (r'$\log(x)$', lambda x: log(x)) ] diff --git a/examples/user_interfaces/svg_histogram.py b/examples/user_interfaces/svg_histogram.py index fff0aa873fb2..adae0469e373 100755 --- a/examples/user_interfaces/svg_histogram.py +++ b/examples/user_interfaces/svg_histogram.py @@ -65,7 +65,7 @@ hist_patches['hist_%d' % ic] = [] for il, element in enumerate(c): element.set_gid('hist_%d_patch_%d' % (ic, il)) - hist_patches['hist_%d' %ic].append('hist_%d_patch_%d' % (ic, il)) + hist_patches['hist_%d' % ic].append('hist_%d_patch_%d' % (ic, il)) # Set ids for the legend patches for i, t in enumerate(leg.get_patches()): diff --git a/examples/widgets/cursor.py b/examples/widgets/cursor.py index 6adcd52407da..2dda520774ee 100644 --- a/examples/widgets/cursor.py +++ b/examples/widgets/cursor.py @@ -8,7 +8,7 @@ fig = plt.figure(figsize=(8, 6)) ax = fig.add_subplot(111, axisbg='#FFFFCC') -x, y = 4*(np.random.rand(2, 100)-.5) +x, y = 4*(np.random.rand(2, 100) - .5) ax.plot(x, y, 'o') ax.set_xlim(-2, 2) ax.set_ylim(-2, 2) diff --git a/examples/widgets/menu.py b/examples/widgets/menu.py index 21de51bffc1f..5ad66834eeb3 100644 --- a/examples/widgets/menu.py +++ b/examples/widgets/menu.py @@ -82,8 +82,8 @@ def set_extent(self, x, y, w, h): self.rect.set_width(w) self.rect.set_height(h) - self.label.ox = x+self.padx - self.label.oy = y-self.depth+self.pady/2. + self.label.ox = x + self.padx + self.label.oy = y - self.depth + self.pady/2. self.rect._update_patch_transform() self.hover = False @@ -129,17 +129,17 @@ def __init__(self, fig, menuitems): maxw = max([item.labelwidth for item in menuitems]) maxh = max([item.labelheight for item in menuitems]) - totalh = self.numitems*maxh + (self.numitems+1)*2*MenuItem.pady + totalh = self.numitems*maxh + (self.numitems + 1)*2*MenuItem.pady x0 = 100 y0 = 400 width = maxw + 2*MenuItem.padx - height = maxh+MenuItem.pady + height = maxh + MenuItem.pady for item in menuitems: left = x0 - bottom = y0-maxh-MenuItem.pady + bottom = y0 - maxh - MenuItem.pady item.set_extent(left, bottom, width, height) From b081c926f8768b3796c8267d09abfba9c44a1640 Mon Sep 17 00:00:00 2001 From: Thomas Hisch Date: Sun, 9 Nov 2014 14:20:48 +0100 Subject: [PATCH 06/26] pep8 fix E701 --- examples/event_handling/data_browser.py | 21 ++++++++---- examples/event_handling/lasso_demo.py | 12 ++++--- examples/event_handling/path_editor.py | 33 ++++++++++++------- examples/event_handling/pick_event_demo.py | 3 +- examples/event_handling/pick_event_demo2.py | 6 ++-- examples/event_handling/poly_editor.py | 33 ++++++++++++------- examples/event_handling/zoom_window.py | 3 +- examples/misc/rc_traits.py | 18 ++++++---- examples/pylab_examples/cursor_demo.py | 6 ++-- examples/pylab_examples/data_helper.py | 3 +- .../pylab_examples/date_index_formatter.py | 3 +- .../pylab_examples/ginput_manual_clabel.py | 6 ++-- examples/pylab_examples/movie_demo.py | 3 +- examples/pylab_examples/toggle_images.py | 3 +- examples/units/evans_test.py | 3 +- examples/user_interfaces/embedding_in_wx5.py | 3 +- examples/user_interfaces/interactive.py | 3 +- examples/widgets/check_buttons.py | 9 +++-- 18 files changed, 114 insertions(+), 57 deletions(-) diff --git a/examples/event_handling/data_browser.py b/examples/event_handling/data_browser.py index 00fe087b6703..5083a0db1f9a 100644 --- a/examples/event_handling/data_browser.py +++ b/examples/event_handling/data_browser.py @@ -17,10 +17,14 @@ def __init__(self): color='yellow', visible=False) def onpress(self, event): - if self.lastind is None: return - if event.key not in ('n', 'p'): return - if event.key == 'n': inc = 1 - else: inc = -1 + if self.lastind is None: + return + if event.key not in ('n', 'p'): + return + if event.key == 'n': + inc = 1 + else: + inc = -1 self.lastind += inc self.lastind = np.clip(self.lastind, 0, len(xs) - 1) @@ -28,10 +32,12 @@ def onpress(self, event): def onpick(self, event): - if event.artist != line: return True + if event.artist != line: + return True N = len(event.ind) - if not N: return True + if not N: + return True # the click locations x = event.mouseevent.xdata @@ -45,7 +51,8 @@ def onpick(self, event): self.update() def update(self): - if self.lastind is None: return + if self.lastind is None: + return dataind = self.lastind diff --git a/examples/event_handling/lasso_demo.py b/examples/event_handling/lasso_demo.py index 5d1f089cbfd5..cd2de76933b2 100644 --- a/examples/event_handling/lasso_demo.py +++ b/examples/event_handling/lasso_demo.py @@ -23,8 +23,10 @@ class Datum(object): def __init__(self, x, y, include=False): self.x = x self.y = y - if include: self.color = self.colorin - else: self.color = self.colorout + if include: + self.color = self.colorin + else: + self.color = self.colorout class LassoManager(object): @@ -63,8 +65,10 @@ def callback(self, verts): del self.lasso def onpress(self, event): - if self.canvas.widgetlock.locked(): return - if event.inaxes is None: return + if self.canvas.widgetlock.locked(): + return + if event.inaxes is None: + return self.lasso = Lasso(event.inaxes, (event.xdata, event.ydata), self.callback) # acquire a lock on the widget drawing self.canvas.widgetlock(self.lasso) diff --git a/examples/event_handling/path_editor.py b/examples/event_handling/path_editor.py index adf983d9def7..a3e43514060a 100644 --- a/examples/event_handling/path_editor.py +++ b/examples/event_handling/path_editor.py @@ -90,33 +90,44 @@ def get_ind_under_point(self, event): def button_press_callback(self, event): 'whenever a mouse button is pressed' - if not self.showverts: return - if event.inaxes == None: return - if event.button != 1: return + if not self.showverts: + return + if event.inaxes == None: + return + if event.button != 1: + return self._ind = self.get_ind_under_point(event) def button_release_callback(self, event): 'whenever a mouse button is released' - if not self.showverts: return - if event.button != 1: return + if not self.showverts: + return + if event.button != 1: + return self._ind = None def key_press_callback(self, event): 'whenever a key is pressed' - if not event.inaxes: return + if not event.inaxes: + return if event.key == 't': self.showverts = not self.showverts self.line.set_visible(self.showverts) - if not self.showverts: self._ind = None + if not self.showverts: + self._ind = None self.canvas.draw() def motion_notify_callback(self, event): 'on mouse movement' - if not self.showverts: return - if self._ind is None: return - if event.inaxes is None: return - if event.button != 1: return + if not self.showverts: + return + if self._ind is None: + return + if event.inaxes is None: + return + if event.button != 1: + return x, y = event.xdata, event.ydata vertices = self.pathpatch.get_path().vertices diff --git a/examples/event_handling/pick_event_demo.py b/examples/event_handling/pick_event_demo.py index 63ec45670ed6..bb3f7751901f 100755 --- a/examples/event_handling/pick_event_demo.py +++ b/examples/event_handling/pick_event_demo.py @@ -116,7 +116,8 @@ def line_picker(line, mouseevent): data coords and attach some extra attributes, pickx and picky which are the data points that were picked """ - if mouseevent.xdata is None: return False, dict() + if mouseevent.xdata is None: + return False, dict() xdata = line.get_xdata() ydata = line.get_ydata() maxd = 0.05 diff --git a/examples/event_handling/pick_event_demo2.py b/examples/event_handling/pick_event_demo2.py index 167ae33b48fb..0e103ebbad8c 100644 --- a/examples/event_handling/pick_event_demo2.py +++ b/examples/event_handling/pick_event_demo2.py @@ -18,10 +18,12 @@ def onpick(event): - if event.artist != line: return True + if event.artist != line: + return True N = len(event.ind) - if not N: return True + if not N: + return True figi = plt.figure() for subplotnum, dataind in enumerate(event.ind): diff --git a/examples/event_handling/poly_editor.py b/examples/event_handling/poly_editor.py index 5a7eed38db06..ba0a6b28e512 100644 --- a/examples/event_handling/poly_editor.py +++ b/examples/event_handling/poly_editor.py @@ -81,24 +81,31 @@ def get_ind_under_point(self, event): def button_press_callback(self, event): 'whenever a mouse button is pressed' - if not self.showverts: return - if event.inaxes == None: return - if event.button != 1: return + if not self.showverts: + return + if event.inaxes == None: + return + if event.button != 1: + return self._ind = self.get_ind_under_point(event) def button_release_callback(self, event): 'whenever a mouse button is released' - if not self.showverts: return - if event.button != 1: return + if not self.showverts: + return + if event.button != 1: + return self._ind = None def key_press_callback(self, event): 'whenever a key is pressed' - if not event.inaxes: return + if not event.inaxes: + return if event.key == 't': self.showverts = not self.showverts self.line.set_visible(self.showverts) - if not self.showverts: self._ind = None + if not self.showverts: + self._ind = None elif event.key == 'd': ind = self.get_ind_under_point(event) if ind is not None: @@ -123,10 +130,14 @@ def key_press_callback(self, event): def motion_notify_callback(self, event): 'on mouse movement' - if not self.showverts: return - if self._ind is None: return - if event.inaxes is None: return - if event.button != 1: return + if not self.showverts: + return + if self._ind is None: + return + if event.inaxes is None: + return + if event.button != 1: + return x, y = event.xdata, event.ydata self.poly.xy[self._ind] = x, y diff --git a/examples/event_handling/zoom_window.py b/examples/event_handling/zoom_window.py index 72952f65f808..91757e9630ba 100644 --- a/examples/event_handling/zoom_window.py +++ b/examples/event_handling/zoom_window.py @@ -28,7 +28,8 @@ def onpress(event): - if event.button != 1: return + if event.button != 1: + return x, y = event.xdata, event.ydata axzoom.set_xlim(x - 0.1, x + 0.1) axzoom.set_ylim(y - 0.1, y + 0.1) diff --git a/examples/misc/rc_traits.py b/examples/misc/rc_traits.py index 32827943ee38..08e236bcf6dd 100644 --- a/examples/misc/rc_traits.py +++ b/examples/misc/rc_traits.py @@ -176,10 +176,14 @@ def __init__(self, ): Artist.__init__(self) - if edgecolor is None: edgecolor = rc.patch.edgecolor - if facecolor is None: facecolor = rc.patch.facecolor - if linewidth is None: linewidth = rc.patch.linewidth - if antialiased is None: antialiased = rc.patch.antialiased + if edgecolor is None: + edgecolor = rc.patch.edgecolor + if facecolor is None: + facecolor = rc.patch.facecolor + if linewidth is None: + linewidth = rc.patch.linewidth + if antialiased is None: + antialiased = rc.patch.antialiased self.edgecolor = edgecolor self.facecolor = facecolor @@ -196,8 +200,10 @@ def __init__(self, p.fill = 'f' print('p.facecolor', type(p.facecolor), p.facecolor) print('p.fill', type(p.fill), p.fill) -if p.fill_: print('fill') -else: print('no fill') +if p.fill_: + print('fill') +else: + print('no fill') if doprint: print() print('Patch') diff --git a/examples/pylab_examples/cursor_demo.py b/examples/pylab_examples/cursor_demo.py index a5fec0550090..aaef587e3820 100755 --- a/examples/pylab_examples/cursor_demo.py +++ b/examples/pylab_examples/cursor_demo.py @@ -24,7 +24,8 @@ def __init__(self, ax): self.txt = ax.text(0.7, 0.9, '', transform=ax.transAxes) def mouse_move(self, event): - if not event.inaxes: return + if not event.inaxes: + return x, y = event.xdata, event.ydata # update the line positions @@ -52,7 +53,8 @@ def __init__(self, ax, x, y): def mouse_move(self, event): - if not event.inaxes: return + if not event.inaxes: + return x, y = event.xdata, event.ydata diff --git a/examples/pylab_examples/data_helper.py b/examples/pylab_examples/data_helper.py index 2e0f2683a45f..ed1153acd752 100755 --- a/examples/pylab_examples/data_helper.py +++ b/examples/pylab_examples/data_helper.py @@ -36,7 +36,8 @@ def get_daily_data(): as numeric arrays """ - class C: pass + class C: + pass def get_ticker(ticker): vals = [] diff --git a/examples/pylab_examples/date_index_formatter.py b/examples/pylab_examples/date_index_formatter.py index 1ff866bb6530..1234bb5b5850 100644 --- a/examples/pylab_examples/date_index_formatter.py +++ b/examples/pylab_examples/date_index_formatter.py @@ -28,7 +28,8 @@ def __init__(self, dates, fmt='%Y-%m-%d'): def __call__(self, x, pos=0): 'Return the label for time x at position pos' ind = int(round(x)) - if ind >= len(self.dates) or ind < 0: return '' + if ind >= len(self.dates) or ind < 0: + return '' return self.dates[ind].strftime(self.fmt) diff --git a/examples/pylab_examples/ginput_manual_clabel.py b/examples/pylab_examples/ginput_manual_clabel.py index 7273454ba37f..ff7d2b2b0e89 100755 --- a/examples/pylab_examples/ginput_manual_clabel.py +++ b/examples/pylab_examples/ginput_manual_clabel.py @@ -54,7 +54,8 @@ def tellme(s): # Get rid of fill if not happy: - for p in ph: p.remove() + for p in ph: + p.remove() ################################################## # Now contour according to distance from triangle @@ -89,7 +90,8 @@ def f(x, y, pts): pts = np.asarray(plt.ginput(2, timeout=-1)) happy = len(pts) < 2 - if happy: break + if happy: + break pts = np.sort(pts, axis=0) plt.axis(pts.T.ravel()) diff --git a/examples/pylab_examples/movie_demo.py b/examples/pylab_examples/movie_demo.py index 0fb0611bfdd0..0d1f7d78666f 100755 --- a/examples/pylab_examples/movie_demo.py +++ b/examples/pylab_examples/movie_demo.py @@ -23,4 +23,5 @@ #os.system("convert _tmp*.png animation.mng") # cleanup -for fname in files: os.remove(fname) +for fname in files: + os.remove(fname) diff --git a/examples/pylab_examples/toggle_images.py b/examples/pylab_examples/toggle_images.py index 9272e776d4f5..e95c54bd20f4 100644 --- a/examples/pylab_examples/toggle_images.py +++ b/examples/pylab_examples/toggle_images.py @@ -33,7 +33,8 @@ def toggle_images(event): 'toggle the visible state of the two images' - if event.key != 't': return + if event.key != 't': + return b1 = im1.get_visible() b2 = im2.get_visible() im1.set_visible(not b1) diff --git a/examples/units/evans_test.py b/examples/units/evans_test.py index c605cc4170d3..8f2686c33e4a 100644 --- a/examples/units/evans_test.py +++ b/examples/units/evans_test.py @@ -16,7 +16,8 @@ def __init__(self, val, unit=1.0): self._val = val * unit def value(self, unit): - if unit is None: unit = self.unit + if unit is None: + unit = self.unit return self._val / unit diff --git a/examples/user_interfaces/embedding_in_wx5.py b/examples/user_interfaces/embedding_in_wx5.py index 7b8efb31aa86..ba5a6b7374e5 100644 --- a/examples/user_interfaces/embedding_in_wx5.py +++ b/examples/user_interfaces/embedding_in_wx5.py @@ -50,4 +50,5 @@ def demo(): frame.Show() app.MainLoop() -if __name__ == "__main__": demo() +if __name__ == "__main__": + demo() diff --git a/examples/user_interfaces/interactive.py b/examples/user_interfaces/interactive.py index 7c8873f652e5..ac0ff15af62c 100755 --- a/examples/user_interfaces/interactive.py +++ b/examples/user_interfaces/interactive.py @@ -225,7 +225,8 @@ def pre_interact(self): else: print('*** Executing file <%s>:' % fname) for line in inFile: - if line.lstrip().find('show()') == 0: continue + if line.lstrip().find('show()') == 0: + continue print('>>', line) push(line) inFile.close() diff --git a/examples/widgets/check_buttons.py b/examples/widgets/check_buttons.py index b9bb1a2cf39d..936e6d96341c 100644 --- a/examples/widgets/check_buttons.py +++ b/examples/widgets/check_buttons.py @@ -18,9 +18,12 @@ def func(label): - if label == '2 Hz': l0.set_visible(not l0.get_visible()) - elif label == '4 Hz': l1.set_visible(not l1.get_visible()) - elif label == '6 Hz': l2.set_visible(not l2.get_visible()) + if label == '2 Hz': + l0.set_visible(not l0.get_visible()) + elif label == '4 Hz': + l1.set_visible(not l1.get_visible()) + elif label == '6 Hz': + l2.set_visible(not l2.get_visible()) plt.draw() check.on_clicked(func) From 0130bb90e0d1257e7c51a0a3dc75911217ee08a7 Mon Sep 17 00:00:00 2001 From: Thomas Hisch Date: Sun, 9 Nov 2014 14:51:10 +0100 Subject: [PATCH 07/26] pep8 fix E502 (redundant backslash) --- .../interpolation_none_vs_nearest.py | 4 +-- examples/pylab_examples/arrow_demo.py | 32 +++++++++---------- examples/pylab_examples/line_collection.py | 2 +- examples/user_interfaces/fourier_demo_wx.py | 12 +++---- 4 files changed, 25 insertions(+), 25 deletions(-) diff --git a/examples/images_contours_and_fields/interpolation_none_vs_nearest.py b/examples/images_contours_and_fields/interpolation_none_vs_nearest.py index c8daa30f5fd4..ef3434d27744 100644 --- a/examples/images_contours_and_fields/interpolation_none_vs_nearest.py +++ b/examples/images_contours_and_fields/interpolation_none_vs_nearest.py @@ -19,7 +19,7 @@ big_im_path = cbook.get_sample_data('necked_tensile_specimen.png') big_im = plt.imread(big_im_path) # Define small image -small_im = np.array([[0.25, 0.75, 1.0, 0.75], [0.1, 0.65, 0.5, 0.4], \ +small_im = np.array([[0.25, 0.75, 1.0, 0.75], [0.1, 0.65, 0.5, 0.4], [0.6, 0.3, 0.0, 0.2], [0.7, 0.9, 0.4, 0.6]]) # Create a 2x2 table of plots @@ -32,7 +32,7 @@ ax.imshow(small_im, interpolation='none') ax = plt.subplot(2, 2, 4) ax.imshow(small_im, interpolation='nearest') -plt.subplots_adjust(left=0.24, wspace=0.2, hspace=0.1, \ +plt.subplots_adjust(left=0.24, wspace=0.2, hspace=0.1, bottom=0.05, top=0.86) # Label the rows and columns of the table diff --git a/examples/pylab_examples/arrow_demo.py b/examples/pylab_examples/arrow_demo.py index b01cfb261d3f..1ced154c4684 100644 --- a/examples/pylab_examples/arrow_demo.py +++ b/examples/pylab_examples/arrow_demo.py @@ -11,7 +11,7 @@ """ from pylab import * -rates_to_bases = {'r1': 'AT', 'r2': 'TA', 'r3': 'GA', 'r4': 'AG', 'r5': 'CA', 'r6': 'AC', \ +rates_to_bases = {'r1': 'AT', 'r2': 'TA', 'r3': 'GA', 'r4': 'AG', 'r5': 'CA', 'r6': 'AC', 'r7': 'GT', 'r8': 'TG', 'r9': 'CT', 'r10': 'TC', 'r11': 'GC', 'r12': 'CG'} numbered_bases_to_rates = dict([(v, k) for k, v in rates_to_bases.items()]) lettered_bases_to_rates = dict([(v, 'r' + v) for k, v in rates_to_bases.items()]) @@ -24,10 +24,10 @@ def add_dicts(d1, d2): return result -def make_arrow_plot(data, size=4, display='length', shape='right', \ - max_arrow_width=0.03, arrow_sep=0.02, alpha=0.5, \ - normalize_data=False, ec=None, labelcolor=None, \ - head_starts_at_zero=True, rate_labels=lettered_bases_to_rates,\ +def make_arrow_plot(data, size=4, display='length', shape='right', + max_arrow_width=0.03, arrow_sep=0.02, alpha=0.5, + normalize_data=False, ec=None, labelcolor=None, + head_starts_at_zero=True, rate_labels=lettered_bases_to_rates, **kwargs): """Makes an arrow plot. @@ -53,11 +53,11 @@ def make_arrow_plot(data, size=4, display='length', shape='right', \ max_text_size = size*12 min_text_size = size label_text_size = size*2.5 - text_params = {'ha': 'center', 'va': 'center', 'family': 'sans-serif',\ + text_params = {'ha': 'center', 'va': 'center', 'family': 'sans-serif', 'fontweight': 'bold'} r2 = sqrt(2) - deltas = {\ + deltas = { 'AT': (1, 0), 'TA': (-1, 0), 'GA': (0, 1), @@ -72,7 +72,7 @@ def make_arrow_plot(data, size=4, display='length', shape='right', \ 'CG': (-1, 0) } - colors = {\ + colors = { 'AT': 'r', 'TA': 'k', 'GA': 'g', @@ -87,7 +87,7 @@ def make_arrow_plot(data, size=4, display='length', shape='right', \ 'CG': 'b' } - label_positions = {\ + label_positions = { 'AT': 'center', 'TA': 'center', 'GA': 'center', @@ -103,7 +103,7 @@ def make_arrow_plot(data, size=4, display='length', shape='right', \ } def do_fontsize(k): - return float(clip(max_text_size*sqrt(data[k]),\ + return float(clip(max_text_size*sqrt(data[k]), min_text_size, max_text_size)) A = text(0, 1, '$A_3$', color='r', size=do_fontsize('A'), **text_params) @@ -117,7 +117,7 @@ def do_fontsize(k): max_arrow_width = max_arrow_width max_head_width = 2.5*max_arrow_width max_head_length = 2*max_arrow_width - arrow_params = {'length_includes_head': True, 'shape': shape, \ + arrow_params = {'length_includes_head': True, 'shape': shape, 'head_starts_at_zero': head_starts_at_zero} ax = gca() sf = 0.6 # max arrow size represents this in data coords @@ -126,7 +126,7 @@ def do_fontsize(k): r2v = arrow_sep/r2 # offset for diags # tuple of x, y for start position - positions = {\ + positions = { 'AT': (arrow_h_offset, 1 + arrow_sep), 'TA': (1 - arrow_h_offset, 1 - arrow_sep), 'GA': (-arrow_sep, arrow_h_offset), @@ -179,8 +179,8 @@ def draw_arrow(pair, alpha=alpha, ec=ec, labelcolor=labelcolor): x_scale, y_scale = deltas[pair] x_pos, y_pos = positions[pair] - arrow(x_pos, y_pos, x_scale*length, y_scale*length, \ - fc=fc, ec=ec, alpha=alpha, width=width, head_width=head_width, \ + arrow(x_pos, y_pos, x_scale*length, y_scale*length, + fc=fc, ec=ec, alpha=alpha, width=width, head_width=head_width, head_length=head_length, **arrow_params) # figure out coordinates for text @@ -209,14 +209,14 @@ def draw_arrow(pair, alpha=alpha, ec=ec, labelcolor=labelcolor): orig_label = rate_labels[pair] label = '$%s_{_{\mathrm{%s}}}$' % (orig_label[0], orig_label[1:]) - text(x, y, label, size=label_text_size, ha='center', va='center', \ + text(x, y, label, size=label_text_size, ha='center', va='center', color=labelcolor or fc) for p in positions.keys(): draw_arrow(p) # test data -all_on_max = dict([(i, 1) for i in 'TCAG'] + \ +all_on_max = dict([(i, 1) for i in 'TCAG'] + [(i + j, 0.6) for i in 'TCAG' for j in 'TCAG']) realistic_data = { diff --git a/examples/pylab_examples/line_collection.py b/examples/pylab_examples/line_collection.py index 1812be905916..9e7ed8f95a07 100644 --- a/examples/pylab_examples/line_collection.py +++ b/examples/pylab_examples/line_collection.py @@ -32,7 +32,7 @@ # See matplotlib.collections.LineCollection for more information line_segments = LineCollection(segs, linewidths=(0.5, 1, 1.5, 2), - colors = [colorConverter.to_rgba(i) \ + colors = [colorConverter.to_rgba(i) for i in ('b', 'g', 'r', 'c', 'm', 'y', 'k')], linestyle = 'solid') ax.add_collection(line_segments) diff --git a/examples/user_interfaces/fourier_demo_wx.py b/examples/user_interfaces/fourier_demo_wx.py index efaaed3152bc..b79605aea199 100644 --- a/examples/user_interfaces/fourier_demo_wx.py +++ b/examples/user_interfaces/fourier_demo_wx.py @@ -99,16 +99,16 @@ def __init__(self, *args, **kwargs): wx.Frame.__init__(self, *args, **kwargs) self.fourierDemoWindow = FourierDemoWindow(self) - self.frequencySliderGroup = SliderGroup(self, label='Frequency f0:', \ + self.frequencySliderGroup = SliderGroup(self, label='Frequency f0:', param=self.fourierDemoWindow.f0) - self.amplitudeSliderGroup = SliderGroup(self, label=' Amplitude a:', \ + self.amplitudeSliderGroup = SliderGroup(self, label=' Amplitude a:', param=self.fourierDemoWindow.A) sizer = wx.BoxSizer(wx.VERTICAL) sizer.Add(self.fourierDemoWindow, 1, wx.EXPAND) - sizer.Add(self.frequencySliderGroup.sizer, 0, \ + sizer.Add(self.frequencySliderGroup.sizer, 0, wx.EXPAND | wx.ALIGN_CENTER | wx.ALL, border=5) - sizer.Add(self.amplitudeSliderGroup.sizer, 0, \ + sizer.Add(self.amplitudeSliderGroup.sizer, 0, wx.EXPAND | wx.ALIGN_CENTER | wx.ALL, border=5) self.SetSizer(sizer) @@ -183,9 +183,9 @@ def draw(self): self.subplot1.set_ylim([0, 1]) self.subplot2.set_xlim([-2, 2]) self.subplot2.set_ylim([-2, 2]) - self.subplot1.text(0.05, .95, r'$X(f) = \mathcal{F}\{x(t)\}$', \ + self.subplot1.text(0.05, .95, r'$X(f) = \mathcal{F}\{x(t)\}$', verticalalignment='top', transform=self.subplot1.transAxes) - self.subplot2.text(0.05, .95, r'$x(t) = a \cdot \cos(2\pi f_0 t) e^{-\pi t^2}$', \ + self.subplot2.text(0.05, .95, r'$x(t) = a \cdot \cos(2\pi f_0 t) e^{-\pi t^2}$', verticalalignment='top', transform=self.subplot2.transAxes) def compute(self, f0, A): From b959c7917bfb35e698cee7d55dfe7746fd092f9b Mon Sep 17 00:00:00 2001 From: Thomas Hisch Date: Sun, 9 Nov 2014 15:05:50 +0100 Subject: [PATCH 08/26] pep8 fix e702,e703 --- examples/event_handling/pipong.py | 4 ++-- examples/lines_bars_and_markers/barh_demo.py | 3 ++- examples/pylab_examples/centered_ticklabels.py | 3 ++- examples/pylab_examples/finance_work2.py | 3 ++- examples/pylab_examples/image_origin.py | 5 +++-- examples/pylab_examples/interp_demo.py | 9 +++++---- examples/pylab_examples/layer_images.py | 3 ++- examples/pylab_examples/quadmesh_demo.py | 4 ++-- examples/pylab_examples/zorder_demo.py | 3 ++- examples/shapes_and_collections/artist_reference.py | 3 ++- examples/user_interfaces/pylab_with_gtk.py | 5 +++-- 11 files changed, 27 insertions(+), 18 deletions(-) diff --git a/examples/event_handling/pipong.py b/examples/event_handling/pipong.py index ae6b264de2c7..d485deb49dc0 100755 --- a/examples/event_handling/pipong.py +++ b/examples/event_handling/pipong.py @@ -82,12 +82,12 @@ def update(self, pads): # probably cleaner with something like...if not self.field.contains(self.x, self.y): if self.x < 0 + fudge: #print("player A loses") - pads[1].score += 1; + pads[1].score += 1 self._reset(pads[0]) return True if self.x > 7 - fudge: #print("player B loses") - pads[0].score += 1; + pads[0].score += 1 self._reset(pads[1]) return True if self.y < -1 + fudge or self.y > 1 - fudge: diff --git a/examples/lines_bars_and_markers/barh_demo.py b/examples/lines_bars_and_markers/barh_demo.py index 2016824cc2ad..38ab12e72c26 100644 --- a/examples/lines_bars_and_markers/barh_demo.py +++ b/examples/lines_bars_and_markers/barh_demo.py @@ -1,7 +1,8 @@ """ Simple demo of a horizontal bar chart. """ -import matplotlib.pyplot as plt; plt.rcdefaults() +import matplotlib.pyplot as plt +plt.rcdefaults() import numpy as np import matplotlib.pyplot as plt diff --git a/examples/pylab_examples/centered_ticklabels.py b/examples/pylab_examples/centered_ticklabels.py index ba496dde7955..1582192a0521 100644 --- a/examples/pylab_examples/centered_ticklabels.py +++ b/examples/pylab_examples/centered_ticklabels.py @@ -20,7 +20,8 @@ # load some financial data; apple's stock price fh = cbook.get_sample_data('aapl.npy.gz') -r = np.load(fh); fh.close() +r = np.load(fh) +fh.close() r = r[-250:] # get the last 250 days fig, ax = plt.subplots() diff --git a/examples/pylab_examples/finance_work2.py b/examples/pylab_examples/finance_work2.py index 4e8cc2143e24..1ed78c5651c4 100644 --- a/examples/pylab_examples/finance_work2.py +++ b/examples/pylab_examples/finance_work2.py @@ -17,7 +17,8 @@ fh = finance.fetch_historical_yahoo(ticker, startdate, enddate) # a numpy record array with fields: date, open, high, low, close, volume, adj_close) -r = mlab.csv2rec(fh); fh.close() +r = mlab.csv2rec(fh) +fh.close() r.sort() diff --git a/examples/pylab_examples/image_origin.py b/examples/pylab_examples/image_origin.py index 397ff2a3c4a4..3375317beb09 100755 --- a/examples/pylab_examples/image_origin.py +++ b/examples/pylab_examples/image_origin.py @@ -7,9 +7,10 @@ """ from pylab import * -x = arange(100.0); x.shape = 10, 10 +x = arange(100.0) +x.shape = 10, 10 -interp = 'bilinear'; +interp = 'bilinear' #interp = 'nearest'; lim = -2, 11, -2, 6 subplot(211, axisbg='g') diff --git a/examples/pylab_examples/interp_demo.py b/examples/pylab_examples/interp_demo.py index 7a1baf9f81e4..978afa4cc5bd 100644 --- a/examples/pylab_examples/interp_demo.py +++ b/examples/pylab_examples/interp_demo.py @@ -2,10 +2,11 @@ from numpy import pi, sin, linspace from matplotlib.mlab import stineman_interp -x = linspace(0, 2*pi, 20); -y = sin(x); yp = None -xi = linspace(x[0], x[-1], 100); -yi = stineman_interp(xi, x, y, yp); +x = linspace(0, 2*pi, 20) +y = sin(x) +yp = None +xi = linspace(x[0], x[-1], 100) +yi = stineman_interp(xi, x, y, yp) fig, ax = plt.subplots() ax.plot(x, y, 'ro', xi, yi, '-b.') diff --git a/examples/pylab_examples/layer_images.py b/examples/pylab_examples/layer_images.py index 9b34972c1702..9374fbed95c1 100644 --- a/examples/pylab_examples/layer_images.py +++ b/examples/pylab_examples/layer_images.py @@ -28,7 +28,8 @@ def func3(x, y): extent = xmin, xmax, ymin, ymax fig = plt.figure(frameon=False) -Z1 = array(([0, 1]*4 + [1, 0]*4)*4); Z1.shape = 8, 8 # chessboard +Z1 = array(([0, 1]*4 + [1, 0]*4)*4) +Z1.shape = 8, 8 # chessboard im1 = imshow(Z1, cmap=cm.gray, interpolation='nearest', extent=extent) hold(True) diff --git a/examples/pylab_examples/quadmesh_demo.py b/examples/pylab_examples/quadmesh_demo.py index 460d32876000..9ffea6bd5b89 100644 --- a/examples/pylab_examples/quadmesh_demo.py +++ b/examples/pylab_examples/quadmesh_demo.py @@ -14,11 +14,11 @@ n = 12 x = np.linspace(-1.5, 1.5, n) y = np.linspace(-1.5, 1.5, n*2) -X, Y = np.meshgrid(x, y); +X, Y = np.meshgrid(x, y) Qx = np.cos(Y) - np.cos(X) Qz = np.sin(Y) + np.sin(X) Qx = (Qx + 1.1) -Z = np.sqrt(X**2 + Y**2)/5; +Z = np.sqrt(X**2 + Y**2)/5 Z = (Z - Z.min()) / (Z.max() - Z.min()) # The color array can include masked values: diff --git a/examples/pylab_examples/zorder_demo.py b/examples/pylab_examples/zorder_demo.py index d0837c89b1b7..0ffb76ccdf6a 100755 --- a/examples/pylab_examples/zorder_demo.py +++ b/examples/pylab_examples/zorder_demo.py @@ -21,7 +21,8 @@ """ from pylab import * -x = rand(20); y = rand(20) +x = rand(20) +y = rand(20) subplot(211) plot(x, y, 'r', lw=3) diff --git a/examples/shapes_and_collections/artist_reference.py b/examples/shapes_and_collections/artist_reference.py index 1af2cd6c78e9..0c03541c8fdb 100644 --- a/examples/shapes_and_collections/artist_reference.py +++ b/examples/shapes_and_collections/artist_reference.py @@ -8,7 +8,8 @@ Copyright (c) 2010, Bartosz Telenczuk BSD License """ -import matplotlib.pyplot as plt; plt.rcdefaults() +import matplotlib.pyplot as plt +plt.rcdefaults() import numpy as np import matplotlib.pyplot as plt diff --git a/examples/user_interfaces/pylab_with_gtk.py b/examples/user_interfaces/pylab_with_gtk.py index 03e3be507f57..06479b03b697 100644 --- a/examples/user_interfaces/pylab_with_gtk.py +++ b/examples/user_interfaces/pylab_with_gtk.py @@ -20,7 +20,7 @@ # now let's add a button to the toolbar import gtk -next = 8; # where to insert this in the mpl toolbar +next = 8 # where to insert this in the mpl toolbar button = gtk.Button('Click me') button.show() @@ -36,7 +36,8 @@ def clicked(button): 'Click me for fun and profit') toolitem.add(button) -toolbar.insert(toolitem, next); next += 1 +toolbar.insert(toolitem, next) +next += 1 # now let's add a widget to the vbox label = gtk.Label() From 712248420fd7b3ff73efb6a080bfcb8ddcc5b344 Mon Sep 17 00:00:00 2001 From: Thomas Hisch Date: Sun, 9 Nov 2014 15:23:22 +0100 Subject: [PATCH 09/26] pep8 fix E302 --- examples/pylab_examples/shading_example.py | 2 ++ examples/specialty_plots/advanced_hillshading.py | 3 +++ 2 files changed, 5 insertions(+) diff --git a/examples/pylab_examples/shading_example.py b/examples/pylab_examples/shading_example.py index 7388c68c04ee..12ce6b379699 100644 --- a/examples/pylab_examples/shading_example.py +++ b/examples/pylab_examples/shading_example.py @@ -9,6 +9,7 @@ # or Generic Mapping Tools # (http://gmt.soest.hawaii.edu/gmt/doc/gmt/html/GMT_Docs/node145.html) + def main(): # Test data x, y = np.mgrid[-5:5:0.05, -5:5:0.05] @@ -26,6 +27,7 @@ def main(): plt.show() + def compare(z, cmap, ve=1): # Create subplots and hide ticks fig, axes = plt.subplots(ncols=2, nrows=2) diff --git a/examples/specialty_plots/advanced_hillshading.py b/examples/specialty_plots/advanced_hillshading.py index 65ab2bc079dc..92b88f426201 100644 --- a/examples/specialty_plots/advanced_hillshading.py +++ b/examples/specialty_plots/advanced_hillshading.py @@ -5,6 +5,7 @@ import matplotlib.pyplot as plt from matplotlib.colors import LightSource, Normalize + def display_colorbar(): """Display a correct numeric colorbar for a shaded plot.""" y, x = np.mgrid[-4:2:200j, -4:2:200j] @@ -24,6 +25,7 @@ def display_colorbar(): ax.set_title('Using a colorbar with a shaded plot', size='x-large') + def avoid_outliers(): """Use a custom norm to control the displayed z-range of a shaded plot.""" y, x = np.mgrid[-4:2:200j, -4:2:200j] @@ -46,6 +48,7 @@ def avoid_outliers(): fig.suptitle('Avoiding Outliers in Shaded Plots', size='x-large') + def shade_other_data(): """Demonstrates displaying different variables through shade and color.""" y, x = np.mgrid[-4:2:200j, -4:2:200j] From fa2ee5000b21477da378f98b443dbdd31d2996b3 Mon Sep 17 00:00:00 2001 From: Thomas Hisch Date: Sun, 9 Nov 2014 14:19:33 +0100 Subject: [PATCH 10/26] remove blacklisted examples from coding style unittest Signed-off-by: Thomas Hisch --- lib/matplotlib/tests/test_coding_standards.py | 23 ++----------------- 1 file changed, 2 insertions(+), 21 deletions(-) diff --git a/lib/matplotlib/tests/test_coding_standards.py b/lib/matplotlib/tests/test_coding_standards.py index ea372a8f0652..8ca84aab9a36 100644 --- a/lib/matplotlib/tests/test_coding_standards.py +++ b/lib/matplotlib/tests/test_coding_standards.py @@ -272,29 +272,10 @@ def test_pep8_conformance_examples(): "of the source tree") exdir = os.path.join(mpldir, 'examples') - blacklist = ['color', - 'event_handling', - 'images_contours_and_fields', - 'lines_bars_and_markers', - 'misc', - 'mplot3d', - 'pie_and_polar_charts', - 'pylab_examples', - 'shapes_and_collections', - 'showcase', - 'specialty_plots', - 'statistics', - 'style_sheets', - 'subplots_axes_and_figures', - 'tests', - 'text_labels_and_annotations', - 'ticks_and_spines', - 'units', - 'user_interfaces', - 'widgets'] + blacklist = () assert_pep8_conformance(dirname=exdir, extra_exclude_directories=blacklist, - expected_bad_files=[]) + expected_bad_files=()) if __name__ == '__main__': From eef2efc0cd2453d816a3f328b5f91063157ea3c8 Mon Sep 17 00:00:00 2001 From: Thomas Hisch Date: Sun, 9 Nov 2014 15:45:46 +0100 Subject: [PATCH 11/26] ignore line to long errors for pep8 unit tests in examples/ --- lib/matplotlib/tests/test_coding_standards.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/lib/matplotlib/tests/test_coding_standards.py b/lib/matplotlib/tests/test_coding_standards.py index 8ca84aab9a36..49972b83813d 100644 --- a/lib/matplotlib/tests/test_coding_standards.py +++ b/lib/matplotlib/tests/test_coding_standards.py @@ -275,6 +275,8 @@ def test_pep8_conformance_examples(): blacklist = () assert_pep8_conformance(dirname=exdir, extra_exclude_directories=blacklist, + pep8_additional_ignore=PEP8_ADDITIONAL_IGNORE + + ['E501'], expected_bad_files=()) From 628955884d4ba8d4a577519e935769c6a06aa8ed Mon Sep 17 00:00:00 2001 From: Thomas Hisch Date: Sun, 9 Nov 2014 16:03:42 +0100 Subject: [PATCH 12/26] pep8 fix E124-E129 Signed-off-by: Thomas Hisch --- examples/api/scatter_piecharts.py | 6 +- examples/axes_grid/demo_floating_axes.py | 2 +- examples/event_handling/data_browser.py | 2 +- examples/event_handling/pipong.py | 10 +- examples/event_handling/zoom_window.py | 2 +- .../interpolation_none_vs_nearest.py | 4 +- examples/misc/contour_manual.py | 2 +- examples/misc/rc_traits.py | 26 ++-- examples/misc/rec_join_demo.py | 4 +- examples/mplot3d/mixed_subplots_demo.py | 2 +- examples/mplot3d/polys3d_demo.py | 2 +- examples/mplot3d/subplot3d_demo.py | 2 +- examples/mplot3d/surface3d_demo.py | 2 +- examples/mplot3d/surface3d_demo3.py | 2 +- .../pie_and_polar_charts/pie_demo_features.py | 8 +- examples/pylab_examples/anchored_artists.py | 2 +- examples/pylab_examples/annotation_demo.py | 2 +- examples/pylab_examples/annotation_demo2.py | 54 ++++---- examples/pylab_examples/arrow_demo.py | 122 +++++++++--------- examples/pylab_examples/axes_zoom_effect.py | 4 +- examples/pylab_examples/barb_demo.py | 8 +- examples/pylab_examples/barchart_demo2.py | 6 +- examples/pylab_examples/boxplot_demo2.py | 22 ++-- examples/pylab_examples/broken_axis.py | 6 +- examples/pylab_examples/broken_barh.py | 2 +- examples/pylab_examples/contour_image.py | 10 +- examples/pylab_examples/contourf_demo.py | 18 +-- examples/pylab_examples/contourf_log.py | 2 +- examples/pylab_examples/dashpointlabel.py | 12 +- .../pylab_examples/demo_annotation_box.py | 2 +- examples/pylab_examples/demo_ribbon_box.py | 4 +- examples/pylab_examples/demo_text_path.py | 2 +- .../pylab_examples/demo_text_rotation_mode.py | 6 +- examples/pylab_examples/ellipse_collection.py | 12 +- examples/pylab_examples/fancytextbox_demo.py | 12 +- examples/pylab_examples/finance_demo.py | 2 +- examples/pylab_examples/fonts_demo_kw.py | 4 +- examples/pylab_examples/gradient_bar.py | 4 +- examples/pylab_examples/image_masked.py | 16 +-- examples/pylab_examples/legend_demo4.py | 2 +- examples/pylab_examples/line_collection.py | 8 +- examples/pylab_examples/line_collection2.py | 4 +- examples/pylab_examples/manual_axis.py | 4 +- examples/pylab_examples/masked_demo.py | 2 +- examples/pylab_examples/multi_image.py | 4 +- examples/pylab_examples/multicolored_line.py | 2 +- examples/pylab_examples/patheffect_demo.py | 2 +- examples/pylab_examples/pie_demo2.py | 4 +- examples/pylab_examples/psd_demo3.py | 4 +- examples/pylab_examples/psd_demo_complex.py | 4 +- examples/pylab_examples/quiver_demo.py | 10 +- examples/pylab_examples/tex_unicode_demo.py | 2 +- examples/pylab_examples/transoffset.py | 8 +- examples/pylab_examples/usetex_demo.py | 2 +- .../artist_reference.py | 22 ++-- .../topographic_hillshading.py | 8 +- examples/statistics/bxp_demo.py | 2 +- .../multiple_histograms_side_by_side.py | 4 +- examples/tests/backend_driver.py | 6 +- .../rainbow_text.py | 6 +- examples/units/ellipse_with_units.py | 8 +- examples/user_interfaces/embedding_in_qt4.py | 4 +- examples/user_interfaces/embedding_in_wx2.py | 2 +- examples/user_interfaces/embedding_in_wx4.py | 2 +- examples/user_interfaces/fourier_demo_wx.py | 12 +- examples/user_interfaces/interactive2.py | 2 +- examples/user_interfaces/svg_histogram.py | 2 +- examples/user_interfaces/wxcursor_demo.py | 6 +- examples/widgets/menu.py | 2 +- 69 files changed, 280 insertions(+), 280 deletions(-) diff --git a/examples/api/scatter_piecharts.py b/examples/api/scatter_piecharts.py index 3950cdef9fc5..2c02294ff166 100644 --- a/examples/api/scatter_piecharts.py +++ b/examples/api/scatter_piecharts.py @@ -37,10 +37,10 @@ fig, ax = plt.subplots() ax.scatter(np.arange(3), np.arange(3), marker=(xy1, 0), - s=[s1*s1*_ for _ in sizes], facecolor='blue') + s=[s1*s1*_ for _ in sizes], facecolor='blue') ax.scatter(np.arange(3), np.arange(3), marker=(xy2, 0), - s=[s2*s2*_ for _ in sizes], facecolor='green') + s=[s2*s2*_ for _ in sizes], facecolor='green') ax.scatter(np.arange(3), np.arange(3), marker=(xy3, 0), - s=[s3*s3*_ for _ in sizes], facecolor='red') + s=[s3*s3*_ for _ in sizes], facecolor='red') plt.show() diff --git a/examples/axes_grid/demo_floating_axes.py b/examples/axes_grid/demo_floating_axes.py index 20286bc8c446..52e62af58e9d 100644 --- a/examples/axes_grid/demo_floating_axes.py +++ b/examples/axes_grid/demo_floating_axes.py @@ -4,7 +4,7 @@ import mpl_toolkits.axisartist.angle_helper as angle_helper from matplotlib.projections import PolarAxes from mpl_toolkits.axisartist.grid_finder import (FixedLocator, MaxNLocator, - DictFormatter) + DictFormatter) import matplotlib.pyplot as plt diff --git a/examples/event_handling/data_browser.py b/examples/event_handling/data_browser.py index 5083a0db1f9a..7bafd58f9708 100644 --- a/examples/event_handling/data_browser.py +++ b/examples/event_handling/data_browser.py @@ -14,7 +14,7 @@ def __init__(self): self.text = ax.text(0.05, 0.95, 'selected: none', transform=ax.transAxes, va='top') self.selected, = ax.plot([xs[0]], [ys[0]], 'o', ms=12, alpha=0.4, - color='yellow', visible=False) + color='yellow', visible=False) def onpress(self, event): if self.lastind is None: diff --git a/examples/event_handling/pipong.py b/examples/event_handling/pipong.py index d485deb49dc0..51c587145b4f 100755 --- a/examples/event_handling/pipong.py +++ b/examples/event_handling/pipong.py @@ -149,11 +149,11 @@ def __init__(self, ax): self.pads.append(Pad(pB, padBx, padBy, 'r')) self.pucks = [] self.i = self.ax.annotate(instructions, (.5, 0.5), - name='monospace', - verticalalignment='center', - horizontalalignment='center', - multialignment='left', - textcoords='axes fraction', animated=True) + name='monospace', + verticalalignment='center', + horizontalalignment='center', + multialignment='left', + textcoords='axes fraction', animated=True) self.canvas.mpl_connect('key_press_event', self.key_press) def draw(self, evt): diff --git a/examples/event_handling/zoom_window.py b/examples/event_handling/zoom_window.py index 91757e9630ba..130074aaa1bb 100644 --- a/examples/event_handling/zoom_window.py +++ b/examples/event_handling/zoom_window.py @@ -16,7 +16,7 @@ axsrc = figsrc.add_subplot(111, xlim=(0, 1), ylim=(0, 1), autoscale_on=False) axzoom = figzoom.add_subplot(111, xlim=(0.45, 0.55), ylim=(0.4, .6), - autoscale_on=False) + autoscale_on=False) axsrc.set_title('Click to zoom') axzoom.set_title('zoom window') x, y, s, c = numpy.random.rand(4, 200) diff --git a/examples/images_contours_and_fields/interpolation_none_vs_nearest.py b/examples/images_contours_and_fields/interpolation_none_vs_nearest.py index ef3434d27744..802c2d1e617a 100644 --- a/examples/images_contours_and_fields/interpolation_none_vs_nearest.py +++ b/examples/images_contours_and_fields/interpolation_none_vs_nearest.py @@ -20,7 +20,7 @@ big_im = plt.imread(big_im_path) # Define small image small_im = np.array([[0.25, 0.75, 1.0, 0.75], [0.1, 0.65, 0.5, 0.4], - [0.6, 0.3, 0.0, 0.2], [0.7, 0.9, 0.4, 0.6]]) + [0.6, 0.3, 0.0, 0.2], [0.7, 0.9, 0.4, 0.6]]) # Create a 2x2 table of plots fig = plt.figure(figsize=[8.0, 7.5]) @@ -33,7 +33,7 @@ ax = plt.subplot(2, 2, 4) ax.imshow(small_im, interpolation='nearest') plt.subplots_adjust(left=0.24, wspace=0.2, hspace=0.1, - bottom=0.05, top=0.86) + bottom=0.05, top=0.86) # Label the rows and columns of the table fig.text(0.03, 0.645, 'Big Image\nScaled Down', ha='left') diff --git a/examples/misc/contour_manual.py b/examples/misc/contour_manual.py index 3a2905685ecf..37d06d0b17e8 100644 --- a/examples/misc/contour_manual.py +++ b/examples/misc/contour_manual.py @@ -14,7 +14,7 @@ # Points can be ordered clockwise or anticlockwise. filled01 = [[[0, 0], [0, 4], [1, 3], [1, 2], [2, 0]]] filled12 = [[[2, 0], [3, 0], [3, 2], [1, 3], [1, 2]], # Note two polygons. - [[1, 4], [3, 4], [3, 3]]] + [[1, 4], [3, 4], [3, 3]]] plt.figure() diff --git a/examples/misc/rc_traits.py b/examples/misc/rc_traits.py index 08e236bcf6dd..45a60bed622a 100644 --- a/examples/misc/rc_traits.py +++ b/examples/misc/rc_traits.py @@ -14,8 +14,8 @@ flexible_true_trait = traits.Trait( True, {'true': True, 't': True, 'yes': True, 'y': True, 'on': True, True: True, - 'false': False, 'f': False, 'no': False, 'n': False, 'off': False, False: False - }) + 'false': False, 'f': False, 'no': False, 'n': False, 'off': False, False: False + }) flexible_false_trait = traits.Trait(False, flexible_true_trait) colors = { @@ -95,7 +95,7 @@ def float_to_rgba(ob, name, val): Color = traits.Trait(RGBA(), float_to_rgba, colorname_to_rgba, RGBA, - hex_to_rgba, tuple_to_rgba) + hex_to_rgba, tuple_to_rgba) def file_exists(ob, name, val): @@ -105,14 +105,14 @@ def file_exists(ob, name, val): linestyles = ('-', '--', '-.', ':', 'steps', 'None') TICKLEFT, TICKRIGHT, TICKUP, TICKDOWN = range(4) linemarkers = (None, '.', ',', 'o', '^', 'v', '<', '>', 's', - '+', 'x', 'd', 'D', '|', '_', 'h', 'H', - 'p', '1', '2', '3', '4', - TICKLEFT, - TICKRIGHT, - TICKUP, - TICKDOWN, - 'None' - ) + '+', 'x', 'd', 'D', '|', '_', 'h', 'H', + 'p', '1', '2', '3', '4', + TICKLEFT, + TICKRIGHT, + TICKUP, + TICKDOWN, + 'None' + ) class LineRC(traits.HasTraits): @@ -136,8 +136,8 @@ class PatchRC(traits.HasTraits): timezones = 'UTC', 'US/Central', 'ES/Eastern' # fixme: and many more backends = ('GTKAgg', 'Cairo', 'GDK', 'GTK', 'Agg', - 'GTKCairo', 'PS', 'SVG', 'Template', 'TkAgg', - 'WX') + 'GTKCairo', 'PS', 'SVG', 'Template', 'TkAgg', + 'WX') class RC(traits.HasTraits): diff --git a/examples/misc/rec_join_demo.py b/examples/misc/rec_join_demo.py index d2a4393fc2fa..6d365042b35b 100644 --- a/examples/misc/rec_join_demo.py +++ b/examples/misc/rec_join_demo.py @@ -12,7 +12,7 @@ # Create a new array r2 = np.empty(12, dtype=[('date', '|O4'), ('high', np.float), - ('marker', np.float)]) + ('marker', np.float)]) r2 = r2.view(np.recarray) r2.date = r.date[-17:-5] r2.high = r.high[-17:-5] @@ -27,5 +27,5 @@ for s in ('inner', 'outer', 'leftouter'): rec = mlab.rec_join(['date', 'high'], r1, r2, - jointype=s, defaults=defaults) + jointype=s, defaults=defaults) print("\n%sjoin :\n%s" % (s, mlab.rec2txt(rec))) diff --git a/examples/mplot3d/mixed_subplots_demo.py b/examples/mplot3d/mixed_subplots_demo.py index cca9cc604cdc..ffcb23c01c21 100644 --- a/examples/mplot3d/mixed_subplots_demo.py +++ b/examples/mplot3d/mixed_subplots_demo.py @@ -42,7 +42,7 @@ def f(t): Z = np.sin(R) surf = ax.plot_surface(X, Y, Z, rstride=1, cstride=1, - linewidth=0, antialiased=False) + linewidth=0, antialiased=False) ax.set_zlim3d(-1, 1) diff --git a/examples/mplot3d/polys3d_demo.py b/examples/mplot3d/polys3d_demo.py index 7a013474f62d..fe0be2ac70b2 100644 --- a/examples/mplot3d/polys3d_demo.py +++ b/examples/mplot3d/polys3d_demo.py @@ -18,7 +18,7 @@ verts.append(list(zip(xs, ys))) poly = PolyCollection(verts, facecolors=[cc('r'), cc('g'), cc('b'), - cc('y')]) + cc('y')]) poly.set_alpha(0.7) ax.add_collection3d(poly, zs=zs, zdir='y') diff --git a/examples/mplot3d/subplot3d_demo.py b/examples/mplot3d/subplot3d_demo.py index 693599da57a4..557f11602fea 100644 --- a/examples/mplot3d/subplot3d_demo.py +++ b/examples/mplot3d/subplot3d_demo.py @@ -18,7 +18,7 @@ R = np.sqrt(X**2 + Y**2) Z = np.sin(R) surf = ax.plot_surface(X, Y, Z, rstride=1, cstride=1, cmap=cm.coolwarm, - linewidth=0, antialiased=False) + linewidth=0, antialiased=False) ax.set_zlim3d(-1.01, 1.01) fig.colorbar(surf, shrink=0.5, aspect=10) diff --git a/examples/mplot3d/surface3d_demo.py b/examples/mplot3d/surface3d_demo.py index bf27c10099f4..f5c7c1392e98 100644 --- a/examples/mplot3d/surface3d_demo.py +++ b/examples/mplot3d/surface3d_demo.py @@ -12,7 +12,7 @@ R = np.sqrt(X**2 + Y**2) Z = np.sin(R) surf = ax.plot_surface(X, Y, Z, rstride=1, cstride=1, cmap=cm.coolwarm, - linewidth=0, antialiased=False) + linewidth=0, antialiased=False) ax.set_zlim(-1.01, 1.01) ax.zaxis.set_major_locator(LinearLocator(10)) diff --git a/examples/mplot3d/surface3d_demo3.py b/examples/mplot3d/surface3d_demo3.py index ba1310e31e41..d23721c28810 100644 --- a/examples/mplot3d/surface3d_demo3.py +++ b/examples/mplot3d/surface3d_demo3.py @@ -21,7 +21,7 @@ colors[x, y] = colortuple[(x + y) % len(colortuple)] surf = ax.plot_surface(X, Y, Z, rstride=1, cstride=1, facecolors=colors, - linewidth=0, antialiased=False) + linewidth=0, antialiased=False) ax.set_zlim3d(-1, 1) ax.w_zaxis.set_major_locator(LinearLocator(6)) diff --git a/examples/pie_and_polar_charts/pie_demo_features.py b/examples/pie_and_polar_charts/pie_demo_features.py index e3619677afdd..ed17febb1705 100644 --- a/examples/pie_and_polar_charts/pie_demo_features.py +++ b/examples/pie_and_polar_charts/pie_demo_features.py @@ -34,16 +34,16 @@ import numpy as np ax.pie(np.random.random(4), explode=explode, labels=labels, colors=colors, - autopct='%1.1f%%', shadow=True, startangle=90, + autopct='%1.1f%%', shadow=True, startangle=90, radius=0.25, center=(0, 0), frame=True) ax.pie(np.random.random(4), explode=explode, labels=labels, colors=colors, - autopct='%1.1f%%', shadow=True, startangle=90, + autopct='%1.1f%%', shadow=True, startangle=90, radius=0.25, center=(1, 1), frame=True) ax.pie(np.random.random(4), explode=explode, labels=labels, colors=colors, - autopct='%1.1f%%', shadow=True, startangle=90, + autopct='%1.1f%%', shadow=True, startangle=90, radius=0.25, center=(0, 1), frame=True) ax.pie(np.random.random(4), explode=explode, labels=labels, colors=colors, - autopct='%1.1f%%', shadow=True, startangle=90, + autopct='%1.1f%%', shadow=True, startangle=90, radius=0.25, center=(1, 0), frame=True) ax.set_xticks([0, 1]) diff --git a/examples/pylab_examples/anchored_artists.py b/examples/pylab_examples/anchored_artists.py index 3b3fb835d305..f8600d0cfec4 100644 --- a/examples/pylab_examples/anchored_artists.py +++ b/examples/pylab_examples/anchored_artists.py @@ -1,7 +1,7 @@ from matplotlib.patches import Rectangle, Ellipse from matplotlib.offsetbox import AnchoredOffsetbox, AuxTransformBox, VPacker,\ - TextArea, DrawingArea + TextArea, DrawingArea class AnchoredText(AnchoredOffsetbox): diff --git a/examples/pylab_examples/annotation_demo.py b/examples/pylab_examples/annotation_demo.py index e8ab8ee8e1c6..e58f9cac776f 100644 --- a/examples/pylab_examples/annotation_demo.py +++ b/examples/pylab_examples/annotation_demo.py @@ -133,7 +133,7 @@ horizontalalignment='left', verticalalignment='bottom', clip_on=True, # clip to the axes bounding box - ) + ) ax.set_xlim(-20, 20) ax.set_ylim(-20, 20) diff --git a/examples/pylab_examples/annotation_demo2.py b/examples/pylab_examples/annotation_demo2.py index acd2131d8b77..3276a4d60d3f 100644 --- a/examples/pylab_examples/annotation_demo2.py +++ b/examples/pylab_examples/annotation_demo2.py @@ -70,13 +70,13 @@ ) ann = ax.annotate('', xy=(4., 1.), xycoords='data', - xytext=(4.5, -1), textcoords='data', - arrowprops=dict(arrowstyle="<->", - connectionstyle="bar", - ec="k", - shrinkA=5, shrinkB=5, - ) - ) + xytext=(4.5, -1), textcoords='data', + arrowprops=dict(arrowstyle="<->", + connectionstyle="bar", + ec="k", + shrinkA=5, shrinkB=5, + ) + ) if 1: @@ -126,28 +126,28 @@ ) ann = ax.annotate('wedge', xy=(2., -1), xycoords='data', - xytext=(0, -45), textcoords='offset points', - size=20, - bbox=dict(boxstyle="round", fc=(1.0, 0.7, 0.7), ec=(1., .5, .5)), - arrowprops=dict(arrowstyle="wedge,tail_width=1.", - fc=(1.0, 0.7, 0.7), ec=(1., .5, .5), - patchA=None, - patchB=el, - relpos=(0.2, 0.8), - connectionstyle="arc3,rad=-0.1"), - ) + xytext=(0, -45), textcoords='offset points', + size=20, + bbox=dict(boxstyle="round", fc=(1.0, 0.7, 0.7), ec=(1., .5, .5)), + arrowprops=dict(arrowstyle="wedge,tail_width=1.", + fc=(1.0, 0.7, 0.7), ec=(1., .5, .5), + patchA=None, + patchB=el, + relpos=(0.2, 0.8), + connectionstyle="arc3,rad=-0.1"), + ) ann = ax.annotate('wedge', xy=(2., -1), xycoords='data', - xytext=(35, 0), textcoords='offset points', - size=20, va="center", - bbox=dict(boxstyle="round", fc=(1.0, 0.7, 0.7), ec="none"), - arrowprops=dict(arrowstyle="wedge,tail_width=1.", - fc=(1.0, 0.7, 0.7), ec="none", - patchA=None, - patchB=el, - relpos=(0.2, 0.5), - ) - ) + xytext=(35, 0), textcoords='offset points', + size=20, va="center", + bbox=dict(boxstyle="round", fc=(1.0, 0.7, 0.7), ec="none"), + arrowprops=dict(arrowstyle="wedge,tail_width=1.", + fc=(1.0, 0.7, 0.7), ec="none", + patchA=None, + patchB=el, + relpos=(0.2, 0.5), + ) + ) show() diff --git a/examples/pylab_examples/arrow_demo.py b/examples/pylab_examples/arrow_demo.py index 1ced154c4684..afd4d2a3e30f 100644 --- a/examples/pylab_examples/arrow_demo.py +++ b/examples/pylab_examples/arrow_demo.py @@ -12,7 +12,7 @@ from pylab import * rates_to_bases = {'r1': 'AT', 'r2': 'TA', 'r3': 'GA', 'r4': 'AG', 'r5': 'CA', 'r6': 'AC', - 'r7': 'GT', 'r8': 'TG', 'r9': 'CT', 'r10': 'TC', 'r11': 'GC', 'r12': 'CG'} + 'r7': 'GT', 'r8': 'TG', 'r9': 'CT', 'r10': 'TC', 'r11': 'GC', 'r12': 'CG'} numbered_bases_to_rates = dict([(v, k) for k, v in rates_to_bases.items()]) lettered_bases_to_rates = dict([(v, 'r' + v) for k, v in rates_to_bases.items()]) @@ -25,10 +25,10 @@ def add_dicts(d1, d2): def make_arrow_plot(data, size=4, display='length', shape='right', - max_arrow_width=0.03, arrow_sep=0.02, alpha=0.5, - normalize_data=False, ec=None, labelcolor=None, - head_starts_at_zero=True, rate_labels=lettered_bases_to_rates, - **kwargs): + max_arrow_width=0.03, arrow_sep=0.02, alpha=0.5, + normalize_data=False, ec=None, labelcolor=None, + head_starts_at_zero=True, rate_labels=lettered_bases_to_rates, + **kwargs): """Makes an arrow plot. Parameters: @@ -54,7 +54,7 @@ def make_arrow_plot(data, size=4, display='length', shape='right', min_text_size = size label_text_size = size*2.5 text_params = {'ha': 'center', 'va': 'center', 'family': 'sans-serif', - 'fontweight': 'bold'} + 'fontweight': 'bold'} r2 = sqrt(2) deltas = { @@ -104,7 +104,7 @@ def make_arrow_plot(data, size=4, display='length', shape='right', def do_fontsize(k): return float(clip(max_text_size*sqrt(data[k]), - min_text_size, max_text_size)) + min_text_size, max_text_size)) A = text(0, 1, '$A_3$', color='r', size=do_fontsize('A'), **text_params) T = text(1, 1, '$T_3$', color='k', size=do_fontsize('T'), **text_params) @@ -118,7 +118,7 @@ def do_fontsize(k): max_head_width = 2.5*max_arrow_width max_head_length = 2*max_arrow_width arrow_params = {'length_includes_head': True, 'shape': shape, - 'head_starts_at_zero': head_starts_at_zero} + 'head_starts_at_zero': head_starts_at_zero} ax = gca() sf = 0.6 # max arrow size represents this in data coords @@ -180,8 +180,8 @@ def draw_arrow(pair, alpha=alpha, ec=ec, labelcolor=labelcolor): x_scale, y_scale = deltas[pair] x_pos, y_pos = positions[pair] arrow(x_pos, y_pos, x_scale*length, y_scale*length, - fc=fc, ec=ec, alpha=alpha, width=width, head_width=head_width, - head_length=head_length, **arrow_params) + fc=fc, ec=ec, alpha=alpha, width=width, head_width=head_width, + head_length=head_length, **arrow_params) # figure out coordinates for text # if drawing relative to base: x and y are same as for arrow @@ -210,70 +210,70 @@ def draw_arrow(pair, alpha=alpha, ec=ec, labelcolor=labelcolor): label = '$%s_{_{\mathrm{%s}}}$' % (orig_label[0], orig_label[1:]) text(x, y, label, size=label_text_size, ha='center', va='center', - color=labelcolor or fc) + color=labelcolor or fc) for p in positions.keys(): draw_arrow(p) # test data all_on_max = dict([(i, 1) for i in 'TCAG'] + - [(i + j, 0.6) for i in 'TCAG' for j in 'TCAG']) + [(i + j, 0.6) for i in 'TCAG' for j in 'TCAG']) realistic_data = { - 'A': 0.4, - 'T': 0.3, - 'G': 0.5, - 'C': 0.2, - 'AT': 0.4, - 'AC': 0.3, - 'AG': 0.2, - 'TA': 0.2, - 'TC': 0.3, - 'TG': 0.4, - 'CT': 0.2, - 'CG': 0.3, - 'CA': 0.2, - 'GA': 0.1, - 'GT': 0.4, - 'GC': 0.1, + 'A': 0.4, + 'T': 0.3, + 'G': 0.5, + 'C': 0.2, + 'AT': 0.4, + 'AC': 0.3, + 'AG': 0.2, + 'TA': 0.2, + 'TC': 0.3, + 'TG': 0.4, + 'CT': 0.2, + 'CG': 0.3, + 'CA': 0.2, + 'GA': 0.1, + 'GT': 0.4, + 'GC': 0.1, } extreme_data = { - 'A': 0.75, - 'T': 0.10, - 'G': 0.10, - 'C': 0.05, - 'AT': 0.6, - 'AC': 0.3, - 'AG': 0.1, - 'TA': 0.02, - 'TC': 0.3, - 'TG': 0.01, - 'CT': 0.2, - 'CG': 0.5, - 'CA': 0.2, - 'GA': 0.1, - 'GT': 0.4, - 'GC': 0.2, + 'A': 0.75, + 'T': 0.10, + 'G': 0.10, + 'C': 0.05, + 'AT': 0.6, + 'AC': 0.3, + 'AG': 0.1, + 'TA': 0.02, + 'TC': 0.3, + 'TG': 0.01, + 'CT': 0.2, + 'CG': 0.5, + 'CA': 0.2, + 'GA': 0.1, + 'GT': 0.4, + 'GC': 0.2, } sample_data = { - 'A': 0.2137, - 'T': 0.3541, - 'G': 0.1946, - 'C': 0.2376, - 'AT': 0.0228, - 'AC': 0.0684, - 'AG': 0.2056, - 'TA': 0.0315, - 'TC': 0.0629, - 'TG': 0.0315, - 'CT': 0.1355, - 'CG': 0.0401, - 'CA': 0.0703, - 'GA': 0.1824, - 'GT': 0.0387, - 'GC': 0.1106, + 'A': 0.2137, + 'T': 0.3541, + 'G': 0.1946, + 'C': 0.2376, + 'AT': 0.0228, + 'AC': 0.0684, + 'AG': 0.2056, + 'TA': 0.0315, + 'TC': 0.0629, + 'TG': 0.0315, + 'CT': 0.1355, + 'CG': 0.0401, + 'CA': 0.0703, + 'GA': 0.1824, + 'GT': 0.0387, + 'GC': 0.1106, } @@ -305,7 +305,7 @@ def draw_arrow(pair, alpha=alpha, ec=ec, labelcolor=labelcolor): figure(figsize=(size, size)) make_arrow_plot(d, display=display, linewidth=0.001, edgecolor=None, - normalize_data=scaled, head_starts_at_zero=True, size=size) + normalize_data=scaled, head_starts_at_zero=True, size=size) draw() diff --git a/examples/pylab_examples/axes_zoom_effect.py b/examples/pylab_examples/axes_zoom_effect.py index 5953c14f2de5..e34a3cebc2a3 100644 --- a/examples/pylab_examples/axes_zoom_effect.py +++ b/examples/pylab_examples/axes_zoom_effect.py @@ -1,8 +1,8 @@ from matplotlib.transforms import Bbox, TransformedBbox, \ - blended_transform_factory + blended_transform_factory from mpl_toolkits.axes_grid1.inset_locator import BboxPatch, BboxConnector,\ - BboxConnectorPatch + BboxConnectorPatch def connect_bbox(bbox1, bbox2, diff --git a/examples/pylab_examples/barb_demo.py b/examples/pylab_examples/barb_demo.py index 7c5013e7d5c8..5681dacf4c8e 100644 --- a/examples/pylab_examples/barb_demo.py +++ b/examples/pylab_examples/barb_demo.py @@ -16,7 +16,7 @@ (-1.5, -0.5, -5, 40)] data = np.array(data, dtype=[('x', np.float32), ('y', np.float32), - ('u', np.float32), ('v', np.float32)]) + ('u', np.float32), ('v', np.float32)]) # Default parameters, uniform grid ax = plt.subplot(2, 2, 1) @@ -31,13 +31,13 @@ # don't round the values, and change some of the size parameters ax = plt.subplot(2, 2, 3) ax.barbs(X, Y, U, V, np.sqrt(U*U + V*V), fill_empty=True, rounding=False, - sizes=dict(emptybarb=0.25, spacing=0.2, height=0.3)) + sizes=dict(emptybarb=0.25, spacing=0.2, height=0.3)) # Change colors as well as the increments for parts of the barbs ax = plt.subplot(2, 2, 4) ax.barbs(data['x'], data['y'], data['u'], data['v'], flagcolor='r', - barbcolor=['b', 'g'], barb_increments=dict(half=10, full=20, flag=100), - flip_barb=True) + barbcolor=['b', 'g'], barb_increments=dict(half=10, full=20, flag=100), + flip_barb=True) # Masked arrays are also supported masked_u = np.ma.masked_array(data['u']) diff --git a/examples/pylab_examples/barchart_demo2.py b/examples/pylab_examples/barchart_demo2.py index 389a3872b985..7d1d411d37a5 100644 --- a/examples/pylab_examples/barchart_demo2.py +++ b/examples/pylab_examples/barchart_demo2.py @@ -46,7 +46,7 @@ xticks = pylab.setp(ax2, xticklabels=['0', '10', '20', '30', '40', '50', '60', '70', '80', '90', '100']) ax2.xaxis.grid(True, linestyle='--', which='major', color='grey', -alpha=0.25) + alpha=0.25) # Plot a solid vertical gridline to highlight the median position plt.plot([50, 50], [0, 5], 'grey', alpha=0.25) @@ -78,7 +78,7 @@ def withnew(i, scr): # 0 1 2 3 4 5 6 7 8 9 suffixes = ['th', 'st', 'nd', 'rd', 'th', 'th', 'th', 'th', 'th', 'th'] ax2.set_xlabel('Percentile Ranking Across ' + str(grade) + suffixes[grade] - + ' Grade ' + gender.title() + 's') + + ' Grade ' + gender.title() + 's') # Lastly, write in the ranking inside each bar to aid in interpretation for rect in rects: @@ -109,6 +109,6 @@ def withnew(i, scr): # Center the text vertically in the bar yloc = rect.get_y() + rect.get_height()/2.0 ax1.text(xloc, yloc, rankStr, horizontalalignment=align, - verticalalignment='center', color=clr, weight='bold') + verticalalignment='center', color=clr, weight='bold') plt.show() diff --git a/examples/pylab_examples/boxplot_demo2.py b/examples/pylab_examples/boxplot_demo2.py index c955a4bd35cd..8249c689110f 100644 --- a/examples/pylab_examples/boxplot_demo2.py +++ b/examples/pylab_examples/boxplot_demo2.py @@ -14,7 +14,7 @@ # to make this assessment numDists = 5 randomDists = ['Normal(1,1)', ' Lognormal(1,1)', 'Exp(1)', 'Gumbel(6,4)', - 'Triangular(2,9,11)'] + 'Triangular(2,9,11)'] N = 500 norm = np.random.normal(1, 1, N) logn = np.random.lognormal(1, 1, N) @@ -32,7 +32,7 @@ triaBoot = tria[bootstrapIndices] data = [norm, normBoot, logn, lognBoot, expo, expoBoot, gumb, gumbBoot, - tria, triaBoot] + tria, triaBoot] fig, ax1 = plt.subplots(figsize=(10, 6)) fig.canvas.set_window_title('A Boxplot Example') @@ -46,7 +46,7 @@ # Add a horizontal grid to the plot, but make it very light in color # so we can use it for reading data values but not be distracting ax1.yaxis.grid(True, linestyle='-', which='major', color='lightgrey', - alpha=0.5) + alpha=0.5) # Hide these grid behind plot objects ax1.set_axisbelow(True) @@ -102,19 +102,19 @@ for tick, label in zip(range(numBoxes), ax1.get_xticklabels()): k = tick % 2 ax1.text(pos[tick], top - (top*0.05), upperLabels[tick], - horizontalalignment='center', size='x-small', weight=weights[k], - color=boxColors[k]) + horizontalalignment='center', size='x-small', weight=weights[k], + color=boxColors[k]) # Finally, add a basic legend plt.figtext(0.80, 0.08, str(N) + ' Random Numbers', - backgroundcolor=boxColors[0], color='black', weight='roman', - size='x-small') + backgroundcolor=boxColors[0], color='black', weight='roman', + size='x-small') plt.figtext(0.80, 0.045, 'IID Bootstrap Resample', -backgroundcolor=boxColors[1], - color='white', weight='roman', size='x-small') + backgroundcolor=boxColors[1], + color='white', weight='roman', size='x-small') plt.figtext(0.80, 0.015, '*', color='white', backgroundcolor='silver', - weight='roman', size='medium') + weight='roman', size='medium') plt.figtext(0.815, 0.013, ' Average Value', color='black', weight='roman', - size='x-small') + size='x-small') plt.show() diff --git a/examples/pylab_examples/broken_axis.py b/examples/pylab_examples/broken_axis.py index 6619816fcc7e..e0bdfd51fdef 100644 --- a/examples/pylab_examples/broken_axis.py +++ b/examples/pylab_examples/broken_axis.py @@ -7,9 +7,9 @@ # 30 points between 0 0.2] originally made using np.random.rand(30)*.2 pts = np.array([0.015, 0.166, 0.133, 0.159, 0.041, 0.024, 0.195, - 0.039, 0.161, 0.018, 0.143, 0.056, 0.125, 0.096, 0.094, 0.051, - 0.043, 0.021, 0.138, 0.075, 0.109, 0.195, 0.05 , 0.074, 0.079, - 0.155, 0.02 , 0.01 , 0.061, 0.008]) + 0.039, 0.161, 0.018, 0.143, 0.056, 0.125, 0.096, 0.094, 0.051, + 0.043, 0.021, 0.138, 0.075, 0.109, 0.195, 0.05 , 0.074, 0.079, + 0.155, 0.02 , 0.01 , 0.061, 0.008]) # Now let's make two outlier points which are far away from everything. pts[[3, 14]] += .8 diff --git a/examples/pylab_examples/broken_barh.py b/examples/pylab_examples/broken_barh.py index 5401980d334b..0c21f234b4ff 100644 --- a/examples/pylab_examples/broken_barh.py +++ b/examples/pylab_examples/broken_barh.py @@ -6,7 +6,7 @@ fig, ax = plt.subplots() ax.broken_barh([(110, 30), (150, 10)], (10, 9), facecolors='blue') ax.broken_barh([(10, 50), (100, 20), (130, 10)], (20, 9), - facecolors=('red', 'yellow', 'green')) + facecolors=('red', 'yellow', 'green')) ax.set_ylim(5, 35) ax.set_xlim(0, 200) ax.set_xlabel('seconds since start') diff --git a/examples/pylab_examples/contour_image.py b/examples/pylab_examples/contour_image.py index 653a3153f515..4fa036a9432a 100755 --- a/examples/pylab_examples/contour_image.py +++ b/examples/pylab_examples/contour_image.py @@ -35,9 +35,9 @@ subplot(2, 2, 1) cset1 = contourf(X, Y, Z, levels, - cmap=cm.get_cmap(cmap, len(levels) - 1), - norm=norm, - ) + 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 # either this number or a large number such as the default (256). @@ -47,8 +47,8 @@ # of the polygons in the collections returned by contourf. # Use levels output from previous call to guarantee they are the same. cset2 = contour(X, Y, Z, cset1.levels, - colors='k', - hold='on') + colors='k', + hold='on') # We don't really need dashed contour lines to indicate negative # regions, so let's turn them off. for c in cset2.collections: diff --git a/examples/pylab_examples/contourf_demo.py b/examples/pylab_examples/contourf_demo.py index 098fb9b54ace..64d718d89b9b 100755 --- a/examples/pylab_examples/contourf_demo.py +++ b/examples/pylab_examples/contourf_demo.py @@ -45,9 +45,9 @@ # or leave out the levels kwarg to use all of the original levels. CS2 = plt.contour(CS, levels=CS.levels[::2], - colors='r', - origin=origin, - hold='on') + colors='r', + origin=origin, + hold='on') plt.title('Nonsense (3 masked regions)') plt.xlabel('word length anomaly') @@ -66,9 +66,9 @@ # of colors. levels = [-1.5, -1, -0.5, 0, 0.5, 1] CS3 = plt.contourf(X, Y, Z, levels, - colors=('r', 'g', 'b'), - origin=origin, - extend='both') + colors=('r', 'g', 'b'), + origin=origin, + extend='both') # Our data range extends outside the range of levels; make # data below the lowest contour level yellow, and above the # highest level cyan: @@ -76,9 +76,9 @@ CS3.cmap.set_over('cyan') CS4 = plt.contour(X, Y, Z, levels, - colors=('k',), - linewidths = (3,), - origin = origin) + colors=('k',), + linewidths = (3,), + origin = origin) plt.title('Listed colors (3 masked regions)') plt.clabel(CS4, fmt='%2.1f', colors='w', fontsize=14) diff --git a/examples/pylab_examples/contourf_log.py b/examples/pylab_examples/contourf_log.py index a10879526a67..ceea635c3e95 100644 --- a/examples/pylab_examples/contourf_log.py +++ b/examples/pylab_examples/contourf_log.py @@ -18,7 +18,7 @@ # Needs to have z/colour axis on a log scale so we see both hump and spike. # linear scale only shows the spike. z = (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)) + + 0.1 * bivariate_normal(X, Y, 1.0, 1.0, 0.0, 0.0)) # Put in some negative values (lower left corner) to cause trouble with logs: z[:5, :5] = -1 diff --git a/examples/pylab_examples/dashpointlabel.py b/examples/pylab_examples/dashpointlabel.py index 662fe700ed88..9e8e03bedbbe 100644 --- a/examples/pylab_examples/dashpointlabel.py +++ b/examples/pylab_examples/dashpointlabel.py @@ -24,12 +24,12 @@ (dd, dl, r, dr, dp) = dash_style[i] #print('dashlen call %d' % dl) t = ax.text(x, y, str((x, y)), withdash=True, - dashdirection=dd, - dashlength=dl, - rotation=r, - dashrotation=dr, - dashpush=dp, - ) + dashdirection=dd, + dashlength=dl, + rotation=r, + dashrotation=dr, + dashpush=dp, + ) ax.set_xlim((0.0, 5.0)) ax.set_ylim((0.0, 5.0)) diff --git a/examples/pylab_examples/demo_annotation_box.py b/examples/pylab_examples/demo_annotation_box.py index a29ebfc7ea6c..0bb5c5b81b5e 100644 --- a/examples/pylab_examples/demo_annotation_box.py +++ b/examples/pylab_examples/demo_annotation_box.py @@ -1,6 +1,6 @@ import matplotlib.pyplot as plt from matplotlib.offsetbox import TextArea, DrawingArea, OffsetImage, \ - AnnotationBbox + AnnotationBbox from matplotlib.cbook import get_sample_data import numpy as np diff --git a/examples/pylab_examples/demo_ribbon_box.py b/examples/pylab_examples/demo_ribbon_box.py index 9213a769d90a..53000a0ea9c7 100644 --- a/examples/pylab_examples/demo_ribbon_box.py +++ b/examples/pylab_examples/demo_ribbon_box.py @@ -39,9 +39,9 @@ def get_stretched_image(self, stretch_factor): cut = self.im[self.cut_location, :, :] stretched_image[:, :, :] = cut stretched_image[:self.cut_location, :, :] = \ - self.im[:self.cut_location, :, :] + self.im[:self.cut_location, :, :] stretched_image[-(ny - self.cut_location):, :, :] = \ - self.im[-(ny - self.cut_location):, :, :] + self.im[-(ny - self.cut_location):, :, :] self._cached_im = stretched_image return stretched_image diff --git a/examples/pylab_examples/demo_text_path.py b/examples/pylab_examples/demo_text_path.py index 40292f567fd4..f155fd5dc6f2 100644 --- a/examples/pylab_examples/demo_text_path.py +++ b/examples/pylab_examples/demo_text_path.py @@ -9,7 +9,7 @@ import matplotlib.patches as mpatches from matplotlib.offsetbox import AnnotationBbox,\ - AnchoredOffsetbox, AuxTransformBox + AnchoredOffsetbox, AuxTransformBox from matplotlib.cbook import get_sample_data diff --git a/examples/pylab_examples/demo_text_rotation_mode.py b/examples/pylab_examples/demo_text_rotation_mode.py index 149544e26d7d..661ce28543d6 100644 --- a/examples/pylab_examples/demo_text_rotation_mode.py +++ b/examples/pylab_examples/demo_text_rotation_mode.py @@ -7,9 +7,9 @@ def test_rotation_mode(fig, mode, subplot_location): ha_list = "left center right".split() va_list = "top center baseline bottom".split() grid = ImageGrid(fig, subplot_location, - nrows_ncols=(len(va_list), len(ha_list)), - share_all=True, aspect=True, #label_mode='1', - cbar_mode=None) + nrows_ncols=(len(va_list), len(ha_list)), + share_all=True, aspect=True, #label_mode='1', + cbar_mode=None) for ha, ax in zip(ha_list, grid.axes_row[-1]): ax.axis["bottom"].label.set_text(ha) diff --git a/examples/pylab_examples/ellipse_collection.py b/examples/pylab_examples/ellipse_collection.py index 469e3432125c..67cc01161565 100644 --- a/examples/pylab_examples/ellipse_collection.py +++ b/examples/pylab_examples/ellipse_collection.py @@ -16,12 +16,12 @@ fig, ax = plt.subplots() ec = EllipseCollection( - ww, - hh, - aa, - units='x', - offsets=XY, - transOffset=ax.transData) + ww, + hh, + aa, + units='x', + offsets=XY, + transOffset=ax.transData) ec.set_array((X + Y).ravel()) ax.add_collection(ec) ax.autoscale_view() diff --git a/examples/pylab_examples/fancytextbox_demo.py b/examples/pylab_examples/fancytextbox_demo.py index 1fa56e3ba920..cd339f02ecd8 100644 --- a/examples/pylab_examples/fancytextbox_demo.py +++ b/examples/pylab_examples/fancytextbox_demo.py @@ -3,17 +3,17 @@ plt.text(0.6, 0.5, "test", size=50, rotation=30., ha="center", va="center", bbox=dict(boxstyle="round", - ec=(1., 0.5, 0.5), - fc=(1., 0.8, 0.8), - ) + ec=(1., 0.5, 0.5), + fc=(1., 0.8, 0.8), + ) ) plt.text(0.5, 0.4, "test", size=50, rotation=-30., ha="right", va="top", bbox=dict(boxstyle="square", - ec=(1., 0.5, 0.5), - fc=(1., 0.8, 0.8), - ) + ec=(1., 0.5, 0.5), + fc=(1., 0.8, 0.8), + ) ) diff --git a/examples/pylab_examples/finance_demo.py b/examples/pylab_examples/finance_demo.py index 409b8cdd9a80..c1cc76870fb9 100644 --- a/examples/pylab_examples/finance_demo.py +++ b/examples/pylab_examples/finance_demo.py @@ -1,7 +1,7 @@ #!/usr/bin/env python import matplotlib.pyplot as plt from matplotlib.dates import DateFormatter, WeekdayLocator,\ - DayLocator, MONDAY + DayLocator, MONDAY from matplotlib.finance import quotes_historical_yahoo_ohlc, candlestick_ohlc diff --git a/examples/pylab_examples/fonts_demo_kw.py b/examples/pylab_examples/fonts_demo_kw.py index eaab06d50e1b..d29e0edcc8dc 100644 --- a/examples/pylab_examples/fonts_demo_kw.py +++ b/examples/pylab_examples/fonts_demo_kw.py @@ -43,7 +43,7 @@ for k in range(2): t = text(0.0, yp[k], variant[k], family='serif', variant=variant[k], - **alignment) + **alignment) # Show weight options @@ -53,7 +53,7 @@ for k in range(7): t = text(0.4, yp[k], weight[k], weight=weight[k], - **alignment) + **alignment) # Show size options diff --git a/examples/pylab_examples/gradient_bar.py b/examples/pylab_examples/gradient_bar.py index 9b1331591f9c..714f45f5ac96 100644 --- a/examples/pylab_examples/gradient_bar.py +++ b/examples/pylab_examples/gradient_bar.py @@ -15,11 +15,11 @@ def gbar(ax, x, y, width=0.5, bottom=0): xmin, xmax = xlim = 0, 10 ymin, ymax = ylim = 0, 1 ax = fig.add_subplot(111, xlim=xlim, ylim=ylim, - autoscale_on=False) + autoscale_on=False) X = [[.6, .6], [.7, .7]] ax.imshow(X, interpolation='bicubic', cmap=cm.copper, - extent=(xmin, xmax, ymin, ymax), alpha=1) + extent=(xmin, xmax, ymin, ymax), alpha=1) N = 10 x = arange(N) + 0.25 diff --git a/examples/pylab_examples/image_masked.py b/examples/pylab_examples/image_masked.py index 0117358c19de..5bee884cc044 100644 --- a/examples/pylab_examples/image_masked.py +++ b/examples/pylab_examples/image_masked.py @@ -35,20 +35,20 @@ subplot(1, 2, 1) im = imshow(Zm, interpolation='bilinear', - cmap=palette, - norm=colors.Normalize(vmin=-1.0, vmax=1.0, clip=False), - origin='lower', extent=[-3, 3, -3, 3]) + cmap=palette, + norm=colors.Normalize(vmin=-1.0, vmax=1.0, clip=False), + origin='lower', extent=[-3, 3, -3, 3]) title('Green=low, Red=high, Blue=bad') colorbar(im, extend='both', orientation='horizontal', shrink=0.8) subplot(1, 2, 2) im = imshow(Zm, interpolation='nearest', - cmap=palette, - norm=colors.BoundaryNorm([-1, -0.5, -0.2, 0, 0.2, 0.5, 1], - ncolors=256, clip=False), - origin='lower', extent=[-3, 3, -3, 3]) + cmap=palette, + norm=colors.BoundaryNorm([-1, -0.5, -0.2, 0, 0.2, 0.5, 1], + ncolors=256, clip=False), + origin='lower', extent=[-3, 3, -3, 3]) title('With BoundaryNorm') colorbar(im, extend='both', spacing='proportional', - orientation='horizontal', shrink=0.8) + orientation='horizontal', shrink=0.8) show() diff --git a/examples/pylab_examples/legend_demo4.py b/examples/pylab_examples/legend_demo4.py index d7437e8f3c0f..c9b3e3be976e 100644 --- a/examples/pylab_examples/legend_demo4.py +++ b/examples/pylab_examples/legend_demo4.py @@ -6,7 +6,7 @@ top_ax.bar([0, 1, 2], [0.2, 0.3, 0.1], width=0.4, label="Bar 1", align="center") top_ax.bar([0.5, 1.5, 2.5], [0.3, 0.2, 0.2], color="red", width=0.4, - label="Bar 2", align="center") + label="Bar 2", align="center") top_ax.legend() middle_ax.errorbar([0, 1, 2], [2, 3, 1], xerr=0.4, fmt="s", label="test 1") diff --git a/examples/pylab_examples/line_collection.py b/examples/pylab_examples/line_collection.py index 9e7ed8f95a07..0b7bdb355c12 100644 --- a/examples/pylab_examples/line_collection.py +++ b/examples/pylab_examples/line_collection.py @@ -31,10 +31,10 @@ # If linestyle is omitted, 'solid' is used # See matplotlib.collections.LineCollection for more information line_segments = LineCollection(segs, - linewidths=(0.5, 1, 1.5, 2), - colors = [colorConverter.to_rgba(i) - for i in ('b', 'g', 'r', 'c', 'm', 'y', 'k')], - linestyle = 'solid') + linewidths=(0.5, 1, 1.5, 2), + colors = [colorConverter.to_rgba(i) + for i in ('b', 'g', 'r', 'c', 'm', 'y', 'k')], + linestyle = 'solid') ax.add_collection(line_segments) ax.set_title('Line collection with masked arrays') plt.show() diff --git a/examples/pylab_examples/line_collection2.py b/examples/pylab_examples/line_collection2.py index 36587f13dcd7..9f09a9fa8089 100644 --- a/examples/pylab_examples/line_collection2.py +++ b/examples/pylab_examples/line_collection2.py @@ -22,8 +22,8 @@ # If linestyle is omitted, 'solid' is used # See matplotlib.collections.LineCollection for more information line_segments = LineCollection([list(zip(x, y)) for y in ys], # Make a sequence of x,y pairs - linewidths=(0.5, 1, 1.5, 2), - linestyles = 'solid') + linewidths=(0.5, 1, 1.5, 2), + linestyles = 'solid') line_segments.set_array(x) ax.add_collection(line_segments) fig = gcf() diff --git a/examples/pylab_examples/manual_axis.py b/examples/pylab_examples/manual_axis.py index 13f0f0b8a821..feaf4556a154 100644 --- a/examples/pylab_examples/manual_axis.py +++ b/examples/pylab_examples/manual_axis.py @@ -18,7 +18,7 @@ def make_xaxis(ax, yloc, offset=0.05, **props): locs = [loc for loc in ax.xaxis.get_majorticklocs() if loc >= xmin and loc <= xmax] tickline, = ax.plot(locs, [yloc]*len(locs), linestyle='', - marker=lines.TICKDOWN, **props) + marker=lines.TICKDOWN, **props) axline, = ax.plot([xmin, xmax], [yloc, yloc], **props) tickline.set_clip_on(False) axline.set_clip_on(False) @@ -33,7 +33,7 @@ def make_yaxis(ax, xloc=0, offset=0.05, **props): locs = [loc for loc in ax.yaxis.get_majorticklocs() if loc >= ymin and loc <= ymax] tickline, = ax.plot([xloc]*len(locs), locs, linestyle='', - marker=lines.TICKLEFT, **props) + marker=lines.TICKLEFT, **props) axline, = ax.plot([xloc, xloc], [ymin, ymax], **props) tickline.set_clip_on(False) axline.set_clip_on(False) diff --git a/examples/pylab_examples/masked_demo.py b/examples/pylab_examples/masked_demo.py index 82482b8e38c8..fb962c6ba3fb 100644 --- a/examples/pylab_examples/masked_demo.py +++ b/examples/pylab_examples/masked_demo.py @@ -21,6 +21,6 @@ setp(lines[2], markersize=10) legend(('No mask', 'Masked if > 0.5', 'Masked if < -0.5'), - loc='upper right') + loc='upper right') title('Masked line demo') show() diff --git a/examples/pylab_examples/multi_image.py b/examples/pylab_examples/multi_image.py index c0c771399604..dad829afec93 100644 --- a/examples/pylab_examples/multi_image.py +++ b/examples/pylab_examples/multi_image.py @@ -19,8 +19,8 @@ figtitle = 'Multiple images' t = fig.text(0.5, 0.95, figtitle, - horizontalalignment='center', - fontproperties=FontProperties(size=16)) + horizontalalignment='center', + fontproperties=FontProperties(size=16)) cax = fig.add_axes([0.2, 0.08, 0.6, 0.04]) diff --git a/examples/pylab_examples/multicolored_line.py b/examples/pylab_examples/multicolored_line.py index 85f7a40923d5..78a8ef42f737 100644 --- a/examples/pylab_examples/multicolored_line.py +++ b/examples/pylab_examples/multicolored_line.py @@ -42,7 +42,7 @@ segments = np.concatenate([points[:-1], points[1:]], axis=1) lc = LineCollection(segments, cmap=plt.get_cmap('copper'), - norm=plt.Normalize(0, 10)) + norm=plt.Normalize(0, 10)) lc.set_array(t) lc.set_linewidth(3) diff --git a/examples/pylab_examples/patheffect_demo.py b/examples/pylab_examples/patheffect_demo.py index 89bdb54cfa14..0adac2911987 100644 --- a/examples/pylab_examples/patheffect_demo.py +++ b/examples/pylab_examples/patheffect_demo.py @@ -10,7 +10,7 @@ arrowprops=dict(arrowstyle="->", connectionstyle="angle3", lw=2), size=20, ha="center", path_effects=[PathEffects.withStroke(linewidth=3, - foreground="w")]) + foreground="w")]) txt.arrow_patch.set_path_effects([ PathEffects.Stroke(linewidth=5, foreground="w"), PathEffects.Normal()]) diff --git a/examples/pylab_examples/pie_demo2.py b/examples/pylab_examples/pie_demo2.py index 920737211cfd..43fb4a24a12c 100644 --- a/examples/pylab_examples/pie_demo2.py +++ b/examples/pylab_examples/pie_demo2.py @@ -45,8 +45,8 @@ plt.subplot(the_grid[1, 1], aspect=1) patches, texts, autotexts = plt.pie(fracs, explode=explode, - labels=labels, autopct='%.0f%%', - shadow=False, radius=0.5) + labels=labels, autopct='%.0f%%', + shadow=False, radius=0.5) # Turn off shadow for tiny plot # with exploded slice. for t in texts: diff --git a/examples/pylab_examples/psd_demo3.py b/examples/pylab_examples/psd_demo3.py index e630e36e3320..ab1faf3c5652 100644 --- a/examples/pylab_examples/psd_demo3.py +++ b/examples/pylab_examples/psd_demo3.py @@ -18,7 +18,7 @@ plt.subplot(1, 2, 1) plt.psd(xn, NFFT=301, Fs=fs, window=mlab.window_none, pad_to=1024, - scale_by_freq=True) + scale_by_freq=True) plt.title('Periodogram') plt.yticks(yticks) plt.xticks(xticks) @@ -26,7 +26,7 @@ plt.subplot(1, 2, 2) plt.psd(xn, NFFT=150, Fs=fs, window=mlab.window_none, noverlap=75, pad_to=512, - scale_by_freq=True) + scale_by_freq=True) plt.title('Welch') plt.xticks(xticks) plt.yticks(yticks) diff --git a/examples/pylab_examples/psd_demo_complex.py b/examples/pylab_examples/psd_demo_complex.py index c4f43083cae7..7928cb364331 100644 --- a/examples/pylab_examples/psd_demo_complex.py +++ b/examples/pylab_examples/psd_demo_complex.py @@ -18,7 +18,7 @@ ax = plt.subplot(1, 2, 1) plt.psd(xn, NFFT=301, Fs=fs, window=mlab.window_none, pad_to=1024, - scale_by_freq=True) + scale_by_freq=True) plt.title('Periodogram') plt.yticks(yticks) plt.xticks(xticks) @@ -27,7 +27,7 @@ plt.subplot(1, 2, 2, sharex=ax, sharey=ax) plt.psd(xn, NFFT=150, Fs=fs, window=mlab.window_none, noverlap=75, pad_to=512, - scale_by_freq=True) + scale_by_freq=True) plt.title('Welch') plt.xticks(xticks) plt.yticks(yticks) diff --git a/examples/pylab_examples/quiver_demo.py b/examples/pylab_examples/quiver_demo.py index f0895a5756c1..1cfcb67cb753 100644 --- a/examples/pylab_examples/quiver_demo.py +++ b/examples/pylab_examples/quiver_demo.py @@ -39,7 +39,7 @@ #3 figure() Q = quiver(X[::3, ::3], Y[::3, ::3], U[::3, ::3], V[::3, ::3], - pivot='mid', color='r', units='inches') + pivot='mid', color='r', units='inches') qk = quiverkey(Q, 0.5, 0.03, 1, r'$1 \frac{m}{s}$', fontproperties={'weight': 'bold'}) plot(X[::3, ::3], Y[::3, ::3], 'k.') axis([-1, 7, -1, 7]) @@ -50,8 +50,8 @@ M = sqrt(pow(U, 2) + pow(V, 2)) Q = quiver(X, Y, U, V, M, units='x', pivot='tip', width=0.022, scale=1/0.15) qk = quiverkey(Q, 0.9, 1.05, 1, r'$1 \frac{m}{s}$', - labelpos='E', - fontproperties={'weight': 'bold'}) + labelpos='E', + fontproperties={'weight': 'bold'}) plot(X, Y, 'k.') axis([-1, 7, -1, 7]) title("scales with x view; pivot='tip'") @@ -59,8 +59,8 @@ #5 figure() Q = quiver(X[::3, ::3], Y[::3, ::3], U[::3, ::3], V[::3, ::3], - color='r', units='x', - linewidths=(2,), edgecolors=('k'), headaxislength=5) + color='r', units='x', + linewidths=(2,), edgecolors=('k'), headaxislength=5) qk = quiverkey(Q, 0.5, 0.03, 1, r'$1 \frac{m}{s}$', fontproperties={'weight': 'bold'}) axis([-1, 7, -1, 7]) title("triangular head; scale with x view; black edges") diff --git a/examples/pylab_examples/tex_unicode_demo.py b/examples/pylab_examples/tex_unicode_demo.py index 19f9de7abc4e..a7dc62e75258 100755 --- a/examples/pylab_examples/tex_unicode_demo.py +++ b/examples/pylab_examples/tex_unicode_demo.py @@ -10,7 +10,7 @@ mpl.rcParams['text.latex.unicode'] = True from numpy import arange, cos, pi from matplotlib.pyplot import (figure, axes, plot, xlabel, ylabel, title, - grid, savefig, show) + grid, savefig, show) figure(1, figsize=(6, 4)) ax = axes([0.1, 0.1, 0.8, 0.7]) diff --git a/examples/pylab_examples/transoffset.py b/examples/pylab_examples/transoffset.py index 50f3cc5d52dd..3605f4b5a716 100644 --- a/examples/pylab_examples/transoffset.py +++ b/examples/pylab_examples/transoffset.py @@ -32,7 +32,7 @@ # first; the subplot command above is one way to do this. transOffset = offset_copy(ax.transData, fig=fig, - x=0.05, y=0.10, units='inches') + x=0.05, y=0.10, units='inches') for x, y in zip(X, Y): P.plot((x,), (y,), 'ro') @@ -48,9 +48,9 @@ for x, y in zip(X, Y): P.polar((x,), (y,), 'ro') P.text(x, y, '%d, %d' % (int(x), int(y)), - transform=transOffset, - horizontalalignment='center', - verticalalignment='bottom') + transform=transOffset, + horizontalalignment='center', + verticalalignment='bottom') P.show() diff --git a/examples/pylab_examples/usetex_demo.py b/examples/pylab_examples/usetex_demo.py index c271d46d7edc..07c1ef4cfa55 100644 --- a/examples/pylab_examples/usetex_demo.py +++ b/examples/pylab_examples/usetex_demo.py @@ -37,7 +37,7 @@ # Left Y-axis labels pylab.ylabel(r'\bf{phase field} $\phi$', {'color': 'b', - 'fontsize': 20}) + 'fontsize': 20}) pylab.yticks((0, 0.5, 1), ('0', '.5', '1'), color='k', size=20) # Right Y-axis labels diff --git a/examples/shapes_and_collections/artist_reference.py b/examples/shapes_and_collections/artist_reference.py index 0c03541c8fdb..1771ebfdcc65 100644 --- a/examples/shapes_and_collections/artist_reference.py +++ b/examples/shapes_and_collections/artist_reference.py @@ -63,15 +63,15 @@ def label(xy, text): # add a path patch Path = mpath.Path path_data = [ - (Path.MOVETO, [0.018, -0.110]), - (Path.CURVE4, [-0.031, -0.051]), - (Path.CURVE4, [-0.115, 0.073]), - (Path.CURVE4, [-0.030, 0.073]), - (Path.LINETO, [-0.011, 0.039]), - (Path.CURVE4, [0.043, 0.121]), - (Path.CURVE4, [0.075, -0.005]), - (Path.CURVE4, [0.035, -0.027]), - (Path.CLOSEPOLY, [0.018, -0.110]) + (Path.MOVETO, [0.018, -0.110]), + (Path.CURVE4, [-0.031, -0.051]), + (Path.CURVE4, [-0.115, 0.073]), + (Path.CURVE4, [-0.030, 0.073]), + (Path.LINETO, [-0.011, 0.039]), + (Path.CURVE4, [0.043, 0.121]), + (Path.CURVE4, [0.075, -0.005]), + (Path.CURVE4, [0.035, -0.027]), + (Path.CLOSEPOLY, [0.018, -0.110]) ] codes, verts = zip(*path_data) path = mpath.Path(verts + grid[6], codes) @@ -81,8 +81,8 @@ def label(xy, text): # add a fancy box fancybox = mpatches.FancyBboxPatch( - grid[7] - [0.025, 0.05], 0.05, 0.1, - boxstyle=mpatches.BoxStyle("Round", pad=0.02)) + grid[7] - [0.025, 0.05], 0.05, 0.1, + boxstyle=mpatches.BoxStyle("Round", pad=0.02)) patches.append(fancybox) label(grid[7], "FancyBoxPatch") diff --git a/examples/specialty_plots/topographic_hillshading.py b/examples/specialty_plots/topographic_hillshading.py index 4fd86bab85bd..e105d71f4a0d 100644 --- a/examples/specialty_plots/topographic_hillshading.py +++ b/examples/specialty_plots/topographic_hillshading.py @@ -60,11 +60,11 @@ # Group labels... axes[0, 1].annotate('Vertical Exaggeration', (0.5, 1), xytext=(0, 30), - textcoords='offset points', xycoords='axes fraction', - ha='center', va='bottom', size=20) + textcoords='offset points', xycoords='axes fraction', + ha='center', va='bottom', size=20) axes[2, 0].annotate('Blend Mode', (0, 0.5), xytext=(-30, 0), - textcoords='offset points', xycoords='axes fraction', - ha='right', va='center', size=20, rotation=90) + textcoords='offset points', xycoords='axes fraction', + ha='right', va='center', size=20, rotation=90) fig.subplots_adjust(bottom=0.05, right=0.95) plt.show() diff --git a/examples/statistics/bxp_demo.py b/examples/statistics/bxp_demo.py index fc1753ce57dc..19a6dd2a14f3 100644 --- a/examples/statistics/bxp_demo.py +++ b/examples/statistics/bxp_demo.py @@ -68,7 +68,7 @@ axes[0, 1].set_title('Custom medianprops\nand flierprops', fontsize=fs) axes[1, 0].bxp(stats, meanprops=meanpointprops, meanline=False, - showmeans=True) + showmeans=True) axes[1, 0].set_title('Custom mean\nas point', fontsize=fs) axes[1, 1].bxp(stats, meanprops=meanlineprops, meanline=True, showmeans=True) diff --git a/examples/statistics/multiple_histograms_side_by_side.py b/examples/statistics/multiple_histograms_side_by_side.py index 370ad08eec4d..3b8a1418d06d 100644 --- a/examples/statistics/multiple_histograms_side_by_side.py +++ b/examples/statistics/multiple_histograms_side_by_side.py @@ -12,8 +12,8 @@ number_of_data_points = 1000 labels = ["A", "B", "C"] data_sets = [np.random.normal(0, 1, number_of_data_points), - np.random.normal(6, 1, number_of_data_points), - np.random.normal(-3, 1, number_of_data_points)] + np.random.normal(6, 1, number_of_data_points), + np.random.normal(-3, 1, number_of_data_points)] # Computed quantities to aid plotting hist_range = (np.min(data_sets), np.max(data_sets)) diff --git a/examples/tests/backend_driver.py b/examples/tests/backend_driver.py index 46839e0095ad..de6b04375d46 100755 --- a/examples/tests/backend_driver.py +++ b/examples/tests/backend_driver.py @@ -415,9 +415,9 @@ def drive(backend, directories, python=['python'], switches=[]): for line in open(fullpath): line_lstrip = line.lstrip() if (line_lstrip.startswith('from __future__ import') or - line_lstrip.startswith('matplotlib.use') or - line_lstrip.startswith('savefig') or - line_lstrip.startswith('show')): + line_lstrip.startswith('matplotlib.use') or + line_lstrip.startswith('savefig') or + line_lstrip.startswith('show')): continue tmpfile.write(line) if backend in rcsetup.interactive_bk: diff --git a/examples/text_labels_and_annotations/rainbow_text.py b/examples/text_labels_and_annotations/rainbow_text.py index a1cb340820e8..9d83228c5b47 100644 --- a/examples/text_labels_and_annotations/rainbow_text.py +++ b/examples/text_labels_and_annotations/rainbow_text.py @@ -49,14 +49,14 @@ def rainbow_text(x, y, strings, colors, ax=None, **kw): # vertical version for s, c in zip(strings, colors): text = ax.text(x, y, " " + s + " ", color=c, transform=t, - rotation=90, va='bottom', ha='center', **kw) + rotation=90, va='bottom', ha='center', **kw) text.draw(canvas.get_renderer()) ex = text.get_window_extent() t = transforms.offset_copy(text._transform, y=ex.height, units='dots') rainbow_text(0, 0, "all unicorns poop rainbows ! ! !".split(), - ['red', 'cyan', 'brown', 'green', 'blue', 'purple', 'black'], - size=18) + ['red', 'cyan', 'brown', 'green', 'blue', 'purple', 'black'], + size=18) plt.show() diff --git a/examples/units/ellipse_with_units.py b/examples/units/ellipse_with_units.py index 42f2e3d6fcb4..c810058e63ba 100644 --- a/examples/units/ellipse_with_units.py +++ b/examples/units/ellipse_with_units.py @@ -32,14 +32,14 @@ ax.fill(x, y, alpha=0.2, facecolor='yellow', edgecolor='yellow', linewidth=1, zorder=1) e1 = patches.Ellipse((xcenter, ycenter), width, height, - angle=angle, linewidth=2, fill=False, zorder=2) + angle=angle, linewidth=2, fill=False, zorder=2) ax.add_patch(e1) ax = fig.add_subplot(212, aspect='equal') ax.fill(x, y, alpha=0.2, facecolor='green', edgecolor='green', zorder=1) e2 = patches.Ellipse((xcenter, ycenter), width, height, - angle=angle, linewidth=2, fill=False, zorder=2) + angle=angle, linewidth=2, fill=False, zorder=2) ax.add_patch(e2) @@ -52,14 +52,14 @@ ax.fill(x, y, alpha=0.2, facecolor='yellow', edgecolor='yellow', linewidth=1, zorder=1) e1 = patches.Arc((xcenter, ycenter), width, height, - angle=angle, linewidth=2, fill=False, zorder=2) + angle=angle, linewidth=2, fill=False, zorder=2) ax.add_patch(e1) ax = fig.add_subplot(212, aspect='equal') ax.fill(x, y, alpha=0.2, facecolor='green', edgecolor='green', zorder=1) e2 = patches.Arc((xcenter, ycenter), width, height, - angle=angle, linewidth=2, fill=False, zorder=2) + angle=angle, linewidth=2, fill=False, zorder=2) ax.add_patch(e2) diff --git a/examples/user_interfaces/embedding_in_qt4.py b/examples/user_interfaces/embedding_in_qt4.py index 4dda135eba7f..5590466f7462 100755 --- a/examples/user_interfaces/embedding_in_qt4.py +++ b/examples/user_interfaces/embedding_in_qt4.py @@ -119,7 +119,7 @@ def closeEvent(self, ce): def about(self): QtGui.QMessageBox.about(self, "About", -"""embedding_in_qt4.py example + """embedding_in_qt4.py example Copyright 2005 Florent Rougon, 2006 Darren Dale This program is a simple example of a Qt4 application embedding matplotlib @@ -127,7 +127,7 @@ def about(self): It may be used and modified with no restriction; raw copies as well as modified versions may be distributed without limitation.""" -) + ) qApp = QtGui.QApplication(sys.argv) diff --git a/examples/user_interfaces/embedding_in_wx2.py b/examples/user_interfaces/embedding_in_wx2.py index bf4d5a99ade1..86ef0bc3f295 100644 --- a/examples/user_interfaces/embedding_in_wx2.py +++ b/examples/user_interfaces/embedding_in_wx2.py @@ -30,7 +30,7 @@ class CanvasFrame(wx.Frame): def __init__(self): wx.Frame.__init__(self, None, -1, - 'CanvasFrame', size=(550, 350)) + 'CanvasFrame', size=(550, 350)) self.SetBackgroundColour(wx.NamedColour("WHITE")) diff --git a/examples/user_interfaces/embedding_in_wx4.py b/examples/user_interfaces/embedding_in_wx4.py index 9803aecde5d4..157bd802d0de 100644 --- a/examples/user_interfaces/embedding_in_wx4.py +++ b/examples/user_interfaces/embedding_in_wx4.py @@ -60,7 +60,7 @@ def _on_custom(self, evt): class CanvasFrame(wx.Frame): def __init__(self): wx.Frame.__init__(self, None, -1, - 'CanvasFrame', size=(550, 350)) + 'CanvasFrame', size=(550, 350)) self.SetBackgroundColour(wx.NamedColour("WHITE")) diff --git a/examples/user_interfaces/fourier_demo_wx.py b/examples/user_interfaces/fourier_demo_wx.py index b79605aea199..d03a6e0b89cb 100644 --- a/examples/user_interfaces/fourier_demo_wx.py +++ b/examples/user_interfaces/fourier_demo_wx.py @@ -100,16 +100,16 @@ def __init__(self, *args, **kwargs): self.fourierDemoWindow = FourierDemoWindow(self) self.frequencySliderGroup = SliderGroup(self, label='Frequency f0:', - param=self.fourierDemoWindow.f0) + param=self.fourierDemoWindow.f0) self.amplitudeSliderGroup = SliderGroup(self, label=' Amplitude a:', - param=self.fourierDemoWindow.A) + param=self.fourierDemoWindow.A) sizer = wx.BoxSizer(wx.VERTICAL) sizer.Add(self.fourierDemoWindow, 1, wx.EXPAND) sizer.Add(self.frequencySliderGroup.sizer, 0, - wx.EXPAND | wx.ALIGN_CENTER | wx.ALL, border=5) + wx.EXPAND | wx.ALIGN_CENTER | wx.ALL, border=5) sizer.Add(self.amplitudeSliderGroup.sizer, 0, - wx.EXPAND | wx.ALIGN_CENTER | wx.ALL, border=5) + wx.EXPAND | wx.ALIGN_CENTER | wx.ALL, border=5) self.SetSizer(sizer) @@ -184,9 +184,9 @@ def draw(self): self.subplot2.set_xlim([-2, 2]) self.subplot2.set_ylim([-2, 2]) self.subplot1.text(0.05, .95, r'$X(f) = \mathcal{F}\{x(t)\}$', - verticalalignment='top', transform=self.subplot1.transAxes) + verticalalignment='top', transform=self.subplot1.transAxes) self.subplot2.text(0.05, .95, r'$x(t) = a \cdot \cos(2\pi f_0 t) e^{-\pi t^2}$', - verticalalignment='top', transform=self.subplot2.transAxes) + verticalalignment='top', transform=self.subplot2.transAxes) def compute(self, f0, A): f = np.arange(-6., 6., 0.02) diff --git a/examples/user_interfaces/interactive2.py b/examples/user_interfaces/interactive2.py index de03a04ecd74..abbe3cc31875 100755 --- a/examples/user_interfaces/interactive2.py +++ b/examples/user_interfaces/interactive2.py @@ -353,7 +353,7 @@ def destroy(arg=None): def key_event(widget, event): if gtk.gdk.keyval_name( event.keyval) == 'd' and \ - event.state & gtk.gdk.CONTROL_MASK: + event.state & gtk.gdk.CONTROL_MASK: destroy() return False diff --git a/examples/user_interfaces/svg_histogram.py b/examples/user_interfaces/svg_histogram.py index adae0469e373..f2dffdf6d0c2 100755 --- a/examples/user_interfaces/svg_histogram.py +++ b/examples/user_interfaces/svg_histogram.py @@ -147,7 +147,7 @@ # Add a transition effect css = tree.getchildren()[0][0] css.text = css.text + "g {-webkit-transition:opacity 0.4s ease-out;" + \ - "-moz-transition:opacity 0.4s ease-out;}" + "-moz-transition:opacity 0.4s ease-out;}" # Insert the script and save to file. tree.insert(0, ET.XML(script)) diff --git a/examples/user_interfaces/wxcursor_demo.py b/examples/user_interfaces/wxcursor_demo.py index ae3aaae0bcde..f335377824b6 100644 --- a/examples/user_interfaces/wxcursor_demo.py +++ b/examples/user_interfaces/wxcursor_demo.py @@ -16,7 +16,7 @@ class CanvasFrame(wx.Frame): def __init__(self, ): wx.Frame.__init__(self, None, -1, - 'CanvasFrame', size=(550, 350)) + 'CanvasFrame', size=(550, 350)) self.SetBackgroundColour(wx.NamedColour("WHITE")) @@ -54,8 +54,8 @@ def UpdateStatusBar(self, event): if event.inaxes: x, y = event.xdata, event.ydata self.statusBar.SetStatusText(("x= " + str(x) + - " y=" + str(y)), - 0) + " y=" + str(y)), + 0) class App(wx.App): diff --git a/examples/widgets/menu.py b/examples/widgets/menu.py index 5ad66834eeb3..d6c5be4dfb98 100644 --- a/examples/widgets/menu.py +++ b/examples/widgets/menu.py @@ -49,7 +49,7 @@ def __init__(self, fig, labelstr, props=None, hoverprops=None, if props.fontsize != hoverprops.fontsize: raise NotImplementedError( - 'support for different font sizes not implemented') + 'support for different font sizes not implemented') self.labelwidth = x.shape[1] self.labelheight = x.shape[0] From 16e15667643d01991026bbc437767f89e28770ef Mon Sep 17 00:00:00 2001 From: Thomas Hisch Date: Sun, 9 Nov 2014 19:13:11 +0100 Subject: [PATCH 13/26] pep fix E401 --- examples/event_handling/pong_gtk.py | 3 ++- examples/misc/image_thumbnail.py | 4 +++- examples/misc/rc_traits.py | 4 +++- examples/pylab_examples/stix_fonts_demo.py | 4 +++- examples/user_interfaces/embedding_in_wx3.py | 5 ++++- examples/user_interfaces/interactive2.py | 3 ++- 6 files changed, 17 insertions(+), 6 deletions(-) diff --git a/examples/event_handling/pong_gtk.py b/examples/event_handling/pong_gtk.py index 7c1a837d2ae4..2d4edc6f98eb 100755 --- a/examples/event_handling/pong_gtk.py +++ b/examples/event_handling/pong_gtk.py @@ -7,7 +7,8 @@ # http://www.scipy.org/wikis/topical_software/MatplotlibAnimation import time -import gtk, gobject +import gtk +import gobject import matplotlib matplotlib.use('GTKAgg') diff --git a/examples/misc/image_thumbnail.py b/examples/misc/image_thumbnail.py index 228ad945dbbe..4e3a1dafc032 100644 --- a/examples/misc/image_thumbnail.py +++ b/examples/misc/image_thumbnail.py @@ -6,7 +6,9 @@ from __future__ import print_function # build thumbnails of all images in a directory -import sys, os, glob +import sys +import os +import glob import matplotlib.image as image diff --git a/examples/misc/rc_traits.py b/examples/misc/rc_traits.py index 45a60bed622a..45bdbe079af2 100644 --- a/examples/misc/rc_traits.py +++ b/examples/misc/rc_traits.py @@ -5,7 +5,9 @@ from __future__ import print_function -import sys, os, re +import sys +import os +import re import traits.api as traits from matplotlib.cbook import is_string_like from matplotlib.artist import Artist diff --git a/examples/pylab_examples/stix_fonts_demo.py b/examples/pylab_examples/stix_fonts_demo.py index 85f026f33150..e4fb20821452 100755 --- a/examples/pylab_examples/stix_fonts_demo.py +++ b/examples/pylab_examples/stix_fonts_demo.py @@ -2,7 +2,9 @@ from __future__ import unicode_literals -import os, sys, re +import os +import sys +import re import gc diff --git a/examples/user_interfaces/embedding_in_wx3.py b/examples/user_interfaces/embedding_in_wx3.py index 637c96f9324c..98357ba1aeab 100755 --- a/examples/user_interfaces/embedding_in_wx3.py +++ b/examples/user_interfaces/embedding_in_wx3.py @@ -25,7 +25,10 @@ import wxversion wxversion.ensureMinimal('2.8') -import sys, time, os, gc +import sys +import time +import os +import gc import matplotlib matplotlib.use('WXAgg') import matplotlib.cm as cm diff --git a/examples/user_interfaces/interactive2.py b/examples/user_interfaces/interactive2.py index abbe3cc31875..00fe018ba033 100755 --- a/examples/user_interfaces/interactive2.py +++ b/examples/user_interfaces/interactive2.py @@ -11,7 +11,8 @@ import gtk.gdk import code -import os, sys +import os +import sys import pango import __builtin__ From 1e822e9dfefa6c6b136b93de5034eb30a659514d Mon Sep 17 00:00:00 2001 From: Thomas Hisch Date: Sun, 9 Nov 2014 19:30:00 +0100 Subject: [PATCH 14/26] fix all issues in the output of the pep8 unit test --- examples/event_handling/path_editor.py | 2 +- examples/event_handling/poly_editor.py | 2 +- examples/pylab_examples/broken_axis.py | 8 ++++---- examples/pylab_examples/data_helper.py | 1 + examples/pylab_examples/date_demo1.py | 6 +++--- examples/pylab_examples/histogram_percent_demo.py | 2 +- examples/pylab_examples/line_collection.py | 5 +++-- examples/user_interfaces/embedding_in_tk_canvas.py | 9 +++++---- examples/user_interfaces/interactive.py | 2 +- examples/user_interfaces/interactive2.py | 8 ++++---- examples/user_interfaces/mathtext_wx.py | 8 ++++---- lib/matplotlib/tests/test_coding_standards.py | 2 +- 12 files changed, 29 insertions(+), 26 deletions(-) diff --git a/examples/event_handling/path_editor.py b/examples/event_handling/path_editor.py index a3e43514060a..3921bf71c8cf 100644 --- a/examples/event_handling/path_editor.py +++ b/examples/event_handling/path_editor.py @@ -92,7 +92,7 @@ def button_press_callback(self, event): 'whenever a mouse button is pressed' if not self.showverts: return - if event.inaxes == None: + if event.inaxes is None: return if event.button != 1: return diff --git a/examples/event_handling/poly_editor.py b/examples/event_handling/poly_editor.py index ba0a6b28e512..78510f8d5f3c 100644 --- a/examples/event_handling/poly_editor.py +++ b/examples/event_handling/poly_editor.py @@ -83,7 +83,7 @@ def button_press_callback(self, event): 'whenever a mouse button is pressed' if not self.showverts: return - if event.inaxes == None: + if event.inaxes is None: return if event.button != 1: return diff --git a/examples/pylab_examples/broken_axis.py b/examples/pylab_examples/broken_axis.py index e0bdfd51fdef..3cb83fd58511 100644 --- a/examples/pylab_examples/broken_axis.py +++ b/examples/pylab_examples/broken_axis.py @@ -6,10 +6,10 @@ # 30 points between 0 0.2] originally made using np.random.rand(30)*.2 -pts = np.array([0.015, 0.166, 0.133, 0.159, 0.041, 0.024, 0.195, - 0.039, 0.161, 0.018, 0.143, 0.056, 0.125, 0.096, 0.094, 0.051, - 0.043, 0.021, 0.138, 0.075, 0.109, 0.195, 0.05 , 0.074, 0.079, - 0.155, 0.02 , 0.01 , 0.061, 0.008]) +pts = np.array([ + 0.015, 0.166, 0.133, 0.159, 0.041, 0.024, 0.195, 0.039, 0.161, 0.018, + 0.143, 0.056, 0.125, 0.096, 0.094, 0.051, 0.043, 0.021, 0.138, 0.075, + 0.109, 0.195, 0.050, 0.074, 0.079, 0.155, 0.020, 0.010, 0.061, 0.008]) # Now let's make two outlier points which are far away from everything. pts[[3, 14]] += .8 diff --git a/examples/pylab_examples/data_helper.py b/examples/pylab_examples/data_helper.py index ed1153acd752..291a6dc44813 100755 --- a/examples/pylab_examples/data_helper.py +++ b/examples/pylab_examples/data_helper.py @@ -38,6 +38,7 @@ def get_daily_data(): """ class C: pass + def get_ticker(ticker): vals = [] diff --git a/examples/pylab_examples/date_demo1.py b/examples/pylab_examples/date_demo1.py index 433fa187691b..45fbf128840e 100644 --- a/examples/pylab_examples/date_demo1.py +++ b/examples/pylab_examples/date_demo1.py @@ -25,8 +25,7 @@ months = MonthLocator() # every month yearsFmt = DateFormatter('%Y') -quotes = quotes_historical_yahoo_ochl( - 'INTC', date1, date2) +quotes = quotes_historical_yahoo_ochl('INTC', date1, date2) if len(quotes) == 0: raise SystemExit @@ -44,7 +43,8 @@ # format the coords message box -def price(x): return '$%1.2f' % x +def price(x): + return '$%1.2f' % x ax.fmt_xdata = DateFormatter('%Y-%m-%d') ax.fmt_ydata = price ax.grid(True) diff --git a/examples/pylab_examples/histogram_percent_demo.py b/examples/pylab_examples/histogram_percent_demo.py index 8a43a3302517..9d7b5d34423f 100644 --- a/examples/pylab_examples/histogram_percent_demo.py +++ b/examples/pylab_examples/histogram_percent_demo.py @@ -10,7 +10,7 @@ def to_percent(y, position): s = str(100 * y) # The percent symbol needs escaping in latex - if matplotlib.rcParams['text.usetex'] == True: + if matplotlib.rcParams['text.usetex'] is True: return s + r'$\%$' else: return s + '%' diff --git a/examples/pylab_examples/line_collection.py b/examples/pylab_examples/line_collection.py index 0b7bdb355c12..8ab86ccbff89 100644 --- a/examples/pylab_examples/line_collection.py +++ b/examples/pylab_examples/line_collection.py @@ -32,8 +32,9 @@ # See matplotlib.collections.LineCollection for more information line_segments = LineCollection(segs, linewidths=(0.5, 1, 1.5, 2), - colors = [colorConverter.to_rgba(i) - for i in ('b', 'g', 'r', 'c', 'm', 'y', 'k')], + colors=[colorConverter.to_rgba(i) + for i in ('b', 'g', 'r', 'c', + 'm', 'y', 'k')], linestyle = 'solid') ax.add_collection(line_segments) ax.set_title('Line collection with masked arrays') diff --git a/examples/user_interfaces/embedding_in_tk_canvas.py b/examples/user_interfaces/embedding_in_tk_canvas.py index 9ec6cc766000..d65f596b4e20 100755 --- a/examples/user_interfaces/embedding_in_tk_canvas.py +++ b/examples/user_interfaces/embedding_in_tk_canvas.py @@ -7,9 +7,10 @@ import matplotlib.backends.tkagg as tkagg from matplotlib.backends.backend_agg import FigureCanvasAgg -def draw_figure(canvas, figure, loc=[0,0]): + +def draw_figure(canvas, figure, loc=[0, 0]): """ Draw a matplotlib figure onto a Tk canvas - + loc: location of top-left corner of figure on canvas in pixels. Inspired by matplotlib source: lib/matplotlib/backends/backend_tkagg.py @@ -17,7 +18,7 @@ def draw_figure(canvas, figure, loc=[0,0]): figure_canvas_agg = FigureCanvasAgg(figure) figure_canvas_agg.draw() figure_x, figure_y, figure_w, figure_h = figure.bbox.bounds - figure_w, figure_h = int(figure_w), int(figure_h) + figure_w, figure_h = int(figure_w), int(figure_h) photo = tk.PhotoImage(master=canvas, width=figure_w, height=figure_h) # Position: convert from top-left anchor to center anchor @@ -43,7 +44,7 @@ def draw_figure(canvas, figure, loc=[0,0]): # Create the figure we desire to add to an existing canvas fig = mpl.figure.Figure(figsize=(2, 1)) -ax = fig.add_axes([0,0,1,1]) +ax = fig.add_axes([0, 0, 1, 1]) ax.plot(X, Y) # Keep this handle alive, or else figure will disappear diff --git a/examples/user_interfaces/interactive.py b/examples/user_interfaces/interactive.py index ac0ff15af62c..ec3ab637b97a 100755 --- a/examples/user_interfaces/interactive.py +++ b/examples/user_interfaces/interactive.py @@ -54,7 +54,7 @@ def __init__(self, on_kill=None, *args, **kw): # Check that all things to kill are callable: for _ in on_kill: if not callable(_): - raise TypeError, 'on_kill must be a list of callables' + raise TypeError('on_kill must be a list of callables') self.on_kill = on_kill # Set up tab-completer if has_readline: diff --git a/examples/user_interfaces/interactive2.py b/examples/user_interfaces/interactive2.py index 00fe018ba033..9d809bd9554c 100755 --- a/examples/user_interfaces/interactive2.py +++ b/examples/user_interfaces/interactive2.py @@ -134,7 +134,7 @@ def write(self, text): end = self.buffer.get_end_iter() - if not self.view == None: + if self.view is not None: self.view.scroll_to_mark(self.mark, 0, True, 1, 1) self.buffer.insert_with_tags(end, text, self.style) @@ -225,7 +225,7 @@ def prompt_ps2(self): def write_line(self, text, style=None): start, end = self.text.get_buffer().get_bounds() - if style == None: + if style is None: self.text.get_buffer().insert(end, text) else: self.text.get_buffer().insert_with_tags(end, text, style) @@ -325,7 +325,7 @@ def complete_line(self): completions = [] p = self.completer.complete(token, len(completions)) - while p != None: + while p is not None: completions.append(p) p = self.completer.complete(token, len(completions)) @@ -353,7 +353,7 @@ def destroy(arg=None): gtk.main_quit() def key_event(widget, event): - if gtk.gdk.keyval_name( event.keyval) == 'd' and \ + if gtk.gdk.keyval_name(event.keyval) == 'd' and \ event.state & gtk.gdk.CONTROL_MASK: destroy() return False diff --git a/examples/user_interfaces/mathtext_wx.py b/examples/user_interfaces/mathtext_wx.py index e6956b7235c2..7886e01a4b10 100644 --- a/examples/user_interfaces/mathtext_wx.py +++ b/examples/user_interfaces/mathtext_wx.py @@ -30,10 +30,10 @@ def mathtext_to_wxbitmap(s): ############################################################ functions = [ - (r'$\sin(2 \pi x)$', lambda x: sin(2*pi*x)), - (r'$\frac{4}{3}\pi x^3$', lambda x: (4.0 / 3.0) * pi * x**3), - (r'$\cos(2 \pi x)$', lambda x: cos(2*pi*x)), - (r'$\log(x)$', lambda x: log(x)) + (r'$\sin(2 \pi x)$', lambda x: sin(2*pi*x)), + (r'$\frac{4}{3}\pi x^3$', lambda x: (4.0/3.0)*pi*x**3), + (r'$\cos(2 \pi x)$', lambda x: cos(2*pi*x)), + (r'$\log(x)$', lambda x: log(x)) ] diff --git a/lib/matplotlib/tests/test_coding_standards.py b/lib/matplotlib/tests/test_coding_standards.py index 49972b83813d..f762bba2515a 100644 --- a/lib/matplotlib/tests/test_coding_standards.py +++ b/lib/matplotlib/tests/test_coding_standards.py @@ -276,7 +276,7 @@ def test_pep8_conformance_examples(): assert_pep8_conformance(dirname=exdir, extra_exclude_directories=blacklist, pep8_additional_ignore=PEP8_ADDITIONAL_IGNORE + - ['E501'], + ['E203', 'E228', 'E261', 'E262', 'E501'], expected_bad_files=()) From 85519f08d421aa642aefa38115620da7b0340bd6 Mon Sep 17 00:00:00 2001 From: Thomas Hisch Date: Sun, 9 Nov 2014 21:53:36 +0100 Subject: [PATCH 15/26] decrease the number of ignored pep8 error classes Signed-off-by: Thomas Hisch --- examples/event_handling/pong_gtk.py | 5 ++--- examples/mplot3d/polys3d_demo.py | 5 ++++- examples/pylab_examples/contour_image.py | 3 +-- examples/pylab_examples/demo_agg_filter.py | 2 +- examples/pylab_examples/demo_text_rotation_mode.py | 5 ++--- examples/pylab_examples/fancyarrow_demo.py | 2 +- examples/pylab_examples/pie_demo2.py | 3 +-- examples/pylab_examples/stackplot_demo.py | 5 ++++- examples/pylab_examples/usetex_demo.py | 2 +- examples/user_interfaces/interactive2.py | 2 +- lib/matplotlib/tests/test_coding_standards.py | 2 +- 11 files changed, 19 insertions(+), 17 deletions(-) diff --git a/examples/event_handling/pong_gtk.py b/examples/event_handling/pong_gtk.py index 2d4edc6f98eb..f522f28b7fd2 100755 --- a/examples/event_handling/pong_gtk.py +++ b/examples/event_handling/pong_gtk.py @@ -7,7 +7,6 @@ # http://www.scipy.org/wikis/topical_software/MatplotlibAnimation import time -import gtk import gobject import matplotlib @@ -22,7 +21,7 @@ def start_anim(event): -# gobject.idle_add(animation.draw,animation) + # gobject.idle_add(animation.draw,animation) gobject.timeout_add(10, animation.draw, animation) canvas.mpl_disconnect(start_anim.cid) @@ -33,4 +32,4 @@ def start_anim(event): tstart = time.time() plt.grid() # to ensure proper background restore plt.show() -print('FPS:', animation.cnt/(time.time() - tstart)) +print('FPS: %f' % animation.cnt/(time.time() - tstart)) diff --git a/examples/mplot3d/polys3d_demo.py b/examples/mplot3d/polys3d_demo.py index fe0be2ac70b2..f9f6b97ed7e2 100644 --- a/examples/mplot3d/polys3d_demo.py +++ b/examples/mplot3d/polys3d_demo.py @@ -4,10 +4,13 @@ import matplotlib.pyplot as plt import numpy as np + fig = plt.figure() ax = fig.gca(projection='3d') -cc = lambda arg: colorConverter.to_rgba(arg, alpha=0.6) + +def cc(arg): + return colorConverter.to_rgba(arg, alpha=0.6) xs = np.arange(0, 10, 0.4) verts = [] diff --git a/examples/pylab_examples/contour_image.py b/examples/pylab_examples/contour_image.py index 4fa036a9432a..921d5a8ec226 100755 --- a/examples/pylab_examples/contour_image.py +++ b/examples/pylab_examples/contour_image.py @@ -23,8 +23,7 @@ Z2 = bivariate_normal(X, Y, 1.5, 0.5, 1, 1) Z = (Z1 - Z2) * 10 -levels = arange(-2.0, 1.601, 0.4) # Boost the upper limit to avoid truncation - # errors. +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 diff --git a/examples/pylab_examples/demo_agg_filter.py b/examples/pylab_examples/demo_agg_filter.py index 5eefd75c2e9d..3337497675d2 100644 --- a/examples/pylab_examples/demo_agg_filter.py +++ b/examples/pylab_examples/demo_agg_filter.py @@ -11,7 +11,7 @@ def smooth1d(x, window_len): s = np.r_[2*x[0] - x[window_len:1:-1], x, 2*x[-1] - x[-1:-window_len:-1]] w = np.hanning(window_len) y = np.convolve(w/w.sum(), s, mode='same') - return y[window_len - 1 : -window_len + 1] + return y[window_len-1:-window_len+1] def smooth2d(A, sigma=3): diff --git a/examples/pylab_examples/demo_text_rotation_mode.py b/examples/pylab_examples/demo_text_rotation_mode.py index 661ce28543d6..264aa49e927d 100644 --- a/examples/pylab_examples/demo_text_rotation_mode.py +++ b/examples/pylab_examples/demo_text_rotation_mode.py @@ -1,5 +1,3 @@ - -#clf() from mpl_toolkits.axes_grid1.axes_grid import ImageGrid @@ -8,7 +6,8 @@ def test_rotation_mode(fig, mode, subplot_location): va_list = "top center baseline bottom".split() grid = ImageGrid(fig, subplot_location, nrows_ncols=(len(va_list), len(ha_list)), - share_all=True, aspect=True, #label_mode='1', + share_all=True, aspect=True, + #label_mode='1', cbar_mode=None) for ha, ax in zip(ha_list, grid.axes_row[-1]): diff --git a/examples/pylab_examples/fancyarrow_demo.py b/examples/pylab_examples/fancyarrow_demo.py index 06742f7ff824..6fceb9878d18 100644 --- a/examples/pylab_examples/fancyarrow_demo.py +++ b/examples/pylab_examples/fancyarrow_demo.py @@ -24,7 +24,7 @@ def to_texstring(s): for i, (stylename, styleclass) in enumerate(sorted(styles.items())): x = 3.2 + (i//nrow)*4 - y = (figheight - 0.7 - i%nrow) # /figheight + y = (figheight - 0.7 - i % nrow) # /figheight p = mpatches.Circle((x, y), 0.2, fc="w") ax.add_patch(p) diff --git a/examples/pylab_examples/pie_demo2.py b/examples/pylab_examples/pie_demo2.py index 43fb4a24a12c..c96d5a83ccdc 100644 --- a/examples/pylab_examples/pie_demo2.py +++ b/examples/pylab_examples/pie_demo2.py @@ -44,11 +44,10 @@ plt.subplot(the_grid[1, 1], aspect=1) +# Turn off shadow for tiny plot with exploded slice. patches, texts, autotexts = plt.pie(fracs, explode=explode, labels=labels, autopct='%.0f%%', shadow=False, radius=0.5) - # Turn off shadow for tiny plot - # with exploded slice. for t in texts: t.set_size('smaller') for t in autotexts: diff --git a/examples/pylab_examples/stackplot_demo.py b/examples/pylab_examples/stackplot_demo.py index ba5d1d202f9e..f10ced74a251 100644 --- a/examples/pylab_examples/stackplot_demo.py +++ b/examples/pylab_examples/stackplot_demo.py @@ -1,7 +1,10 @@ import numpy as np from matplotlib import pyplot as plt -fnx = lambda: np.random.randint(5, 50, 10) + +def fnx(): + return np.random.randint(5, 50, 10) + y = np.row_stack((fnx(), fnx(), fnx())) x = np.arange(10) diff --git a/examples/pylab_examples/usetex_demo.py b/examples/pylab_examples/usetex_demo.py index 07c1ef4cfa55..f29173af3f4d 100644 --- a/examples/pylab_examples/usetex_demo.py +++ b/examples/pylab_examples/usetex_demo.py @@ -13,7 +13,7 @@ X, X < 0, 'k--', # sharp interface linewidth=5) -## legend +# legend pylab.legend((r'phase field', r'level set', r'composition', r'sharp interface'), shadow=True, loc=(0.01, 0.55)) ltext = pylab.gca().get_legend().get_texts() diff --git a/examples/user_interfaces/interactive2.py b/examples/user_interfaces/interactive2.py index 9d809bd9554c..6e174b0b7170 100755 --- a/examples/user_interfaces/interactive2.py +++ b/examples/user_interfaces/interactive2.py @@ -169,7 +169,7 @@ def __init__(self): self.mark = self.text.get_buffer().create_mark("End", self.text.get_buffer().get_end_iter(), False) - # setup colors + # setup colors self.style_banner = gtk.TextTag("banner") self.style_banner.set_property("foreground", "saddle brown") diff --git a/lib/matplotlib/tests/test_coding_standards.py b/lib/matplotlib/tests/test_coding_standards.py index f762bba2515a..d8d5ba353d29 100644 --- a/lib/matplotlib/tests/test_coding_standards.py +++ b/lib/matplotlib/tests/test_coding_standards.py @@ -276,7 +276,7 @@ def test_pep8_conformance_examples(): assert_pep8_conformance(dirname=exdir, extra_exclude_directories=blacklist, pep8_additional_ignore=PEP8_ADDITIONAL_IGNORE + - ['E203', 'E228', 'E261', 'E262', 'E501'], + ['E116', 'E501'], expected_bad_files=()) From 111cdabed4058cfdcafba156e3b51b8778c3edf6 Mon Sep 17 00:00:00 2001 From: Thomas Hisch Date: Sun, 9 Nov 2014 22:12:47 +0100 Subject: [PATCH 16/26] consider @weathergods suggestions --- examples/pylab_examples/demo_ribbon_box.py | 4 ++-- examples/pylab_examples/image_origin.py | 2 +- examples/pylab_examples/line_collection.py | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/examples/pylab_examples/demo_ribbon_box.py b/examples/pylab_examples/demo_ribbon_box.py index 53000a0ea9c7..df39dede071a 100644 --- a/examples/pylab_examples/demo_ribbon_box.py +++ b/examples/pylab_examples/demo_ribbon_box.py @@ -39,9 +39,9 @@ def get_stretched_image(self, stretch_factor): cut = self.im[self.cut_location, :, :] stretched_image[:, :, :] = cut stretched_image[:self.cut_location, :, :] = \ - self.im[:self.cut_location, :, :] + self.im[:self.cut_location, :, :] stretched_image[-(ny - self.cut_location):, :, :] = \ - self.im[-(ny - self.cut_location):, :, :] + self.im[-(ny - self.cut_location):, :, :] self._cached_im = stretched_image return stretched_image diff --git a/examples/pylab_examples/image_origin.py b/examples/pylab_examples/image_origin.py index 3375317beb09..2e5d71a2d2ac 100755 --- a/examples/pylab_examples/image_origin.py +++ b/examples/pylab_examples/image_origin.py @@ -11,7 +11,7 @@ x.shape = 10, 10 interp = 'bilinear' -#interp = 'nearest'; +#interp = 'nearest' lim = -2, 11, -2, 6 subplot(211, axisbg='g') title('blue should be up') diff --git a/examples/pylab_examples/line_collection.py b/examples/pylab_examples/line_collection.py index 8ab86ccbff89..94c8e44659a5 100644 --- a/examples/pylab_examples/line_collection.py +++ b/examples/pylab_examples/line_collection.py @@ -35,7 +35,7 @@ colors=[colorConverter.to_rgba(i) for i in ('b', 'g', 'r', 'c', 'm', 'y', 'k')], - linestyle = 'solid') + linestyle='solid') ax.add_collection(line_segments) ax.set_title('Line collection with masked arrays') plt.show() From 192a26cfea4bbc934dd3337d378cd8a0bf43ae0f Mon Sep 17 00:00:00 2001 From: Thomas Hisch Date: Sun, 9 Nov 2014 22:39:57 +0100 Subject: [PATCH 17/26] prettify instantiation of ellipsecollection object --- examples/pylab_examples/ellipse_collection.py | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/examples/pylab_examples/ellipse_collection.py b/examples/pylab_examples/ellipse_collection.py index 67cc01161565..3d98c0c12467 100644 --- a/examples/pylab_examples/ellipse_collection.py +++ b/examples/pylab_examples/ellipse_collection.py @@ -15,13 +15,8 @@ fig, ax = plt.subplots() -ec = EllipseCollection( - ww, - hh, - aa, - units='x', - offsets=XY, - transOffset=ax.transData) +ec = EllipseCollection(ww, hh, aa, units='x', offsets=XY, + transOffset=ax.transData) ec.set_array((X + Y).ravel()) ax.add_collection(ec) ax.autoscale_view() From e53ba3e8fa343af70889707e8aba18f23f88fab4 Mon Sep 17 00:00:00 2001 From: Thomas Hisch Date: Sun, 9 Nov 2014 22:43:33 +0100 Subject: [PATCH 18/26] avoid triple quoted string --- examples/user_interfaces/svg_histogram.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/examples/user_interfaces/svg_histogram.py b/examples/user_interfaces/svg_histogram.py index f2dffdf6d0c2..f360357eed92 100755 --- a/examples/user_interfaces/svg_histogram.py +++ b/examples/user_interfaces/svg_histogram.py @@ -54,8 +54,8 @@ H = plt.hist([r, r1], label=labels) containers = H[-1] leg = plt.legend(frameon=False) -plt.title("""From a web browser, click on the legend -marker to toggle the corresponding histogram.""") +plt.title("From a web browser, click on the legend\n" + "marker to toggle the corresponding histogram.") # --- Add ids to the svg objects we'll modify From 3bd0f577451c1d873b76a65952fcf99738cdf5cc Mon Sep 17 00:00:00 2001 From: Thomas Hisch Date: Sun, 9 Nov 2014 22:43:59 +0100 Subject: [PATCH 19/26] fix mutable default arguments --- examples/user_interfaces/embedding_in_tk_canvas.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/examples/user_interfaces/embedding_in_tk_canvas.py b/examples/user_interfaces/embedding_in_tk_canvas.py index d65f596b4e20..b34431eda0b6 100755 --- a/examples/user_interfaces/embedding_in_tk_canvas.py +++ b/examples/user_interfaces/embedding_in_tk_canvas.py @@ -8,7 +8,7 @@ from matplotlib.backends.backend_agg import FigureCanvasAgg -def draw_figure(canvas, figure, loc=[0, 0]): +def draw_figure(canvas, figure, loc=(0, 0)): """ Draw a matplotlib figure onto a Tk canvas loc: location of top-left corner of figure on canvas in pixels. @@ -49,7 +49,7 @@ def draw_figure(canvas, figure, loc=[0, 0]): # Keep this handle alive, or else figure will disappear fig_x, fig_y = 100, 100 -fig_photo = draw_figure(canvas, fig, loc=[fig_x, fig_y]) +fig_photo = draw_figure(canvas, fig, loc=(fig_x, fig_y)) fig_w, fig_h = fig_photo.width(), fig_photo.height() # Add more elements to the canvas, potentially on top of the figure From 2da662bd99e098bded38d3c46f771712312aef09 Mon Sep 17 00:00:00 2001 From: Thomas Hisch Date: Sun, 9 Nov 2014 22:55:39 +0100 Subject: [PATCH 20/26] don't use implicit tuple assignment --- examples/pylab_examples/image_origin.py | 2 +- examples/pylab_examples/layer_images.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/examples/pylab_examples/image_origin.py b/examples/pylab_examples/image_origin.py index 2e5d71a2d2ac..9084a93720b1 100755 --- a/examples/pylab_examples/image_origin.py +++ b/examples/pylab_examples/image_origin.py @@ -8,7 +8,7 @@ from pylab import * x = arange(100.0) -x.shape = 10, 10 +x.shape = (10, 10) interp = 'bilinear' #interp = 'nearest' diff --git a/examples/pylab_examples/layer_images.py b/examples/pylab_examples/layer_images.py index 9374fbed95c1..8894f3d31d2d 100644 --- a/examples/pylab_examples/layer_images.py +++ b/examples/pylab_examples/layer_images.py @@ -29,7 +29,7 @@ def func3(x, y): fig = plt.figure(frameon=False) Z1 = array(([0, 1]*4 + [1, 0]*4)*4) -Z1.shape = 8, 8 # chessboard +Z1.shape = (8, 8) # chessboard im1 = imshow(Z1, cmap=cm.gray, interpolation='nearest', extent=extent) hold(True) From cb0467d28681b683248599ccd63fe7616ddf9d19 Mon Sep 17 00:00:00 2001 From: Thomas Hisch Date: Sun, 9 Nov 2014 23:00:13 +0100 Subject: [PATCH 21/26] prettify instantiation of Linecollection obj even further --- examples/pylab_examples/line_collection.py | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/examples/pylab_examples/line_collection.py b/examples/pylab_examples/line_collection.py index 94c8e44659a5..2e404559c25b 100644 --- a/examples/pylab_examples/line_collection.py +++ b/examples/pylab_examples/line_collection.py @@ -30,12 +30,10 @@ # 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 -line_segments = LineCollection(segs, - linewidths=(0.5, 1, 1.5, 2), - colors=[colorConverter.to_rgba(i) - for i in ('b', 'g', 'r', 'c', - 'm', 'y', 'k')], - linestyle='solid') +colors = [colorConverter.to_rgba(i) for i in 'bgrcmyk'] + +line_segments = LineCollection(segs, linewidths=(0.5, 1, 1.5, 2), + colors=colors, linestyle='solid') ax.add_collection(line_segments) ax.set_title('Line collection with masked arrays') plt.show() From 2cb5403fd11e32e09fa4903e7d1d53ec252da133 Mon Sep 17 00:00:00 2001 From: Thomas Hisch Date: Mon, 10 Nov 2014 13:52:09 +0100 Subject: [PATCH 22/26] Revert "pep8 fix E201" This reverts commit 3ef582b5c0f34dbc4441d7f083366f5766720890. Conflicts: examples/shapes_and_collections/artist_reference.py --- examples/pylab_examples/table_demo.py | 10 +++++----- examples/pylab_examples/tricontour_demo.py | 18 +++++++++--------- examples/pylab_examples/tripcolor_demo.py | 18 +++++++++--------- examples/pylab_examples/triplot_demo.py | 18 +++++++++--------- .../shapes_and_collections/artist_reference.py | 18 +++++++++--------- 5 files changed, 41 insertions(+), 41 deletions(-) diff --git a/examples/pylab_examples/table_demo.py b/examples/pylab_examples/table_demo.py index fdecf2f0c9e7..8e80056c347d 100644 --- a/examples/pylab_examples/table_demo.py +++ b/examples/pylab_examples/table_demo.py @@ -5,11 +5,11 @@ import matplotlib.pyplot as plt -data = [[66386, 174296, 75131, 577908, 32015], - [58230, 381139, 78045, 99308, 160454], - [89135, 80552, 152558, 497981, 603535], - [78415, 81858, 150656, 193263, 69638], - [139361, 331509, 343164, 781380, 52269]] +data = [[ 66386, 174296, 75131, 577908, 32015], + [ 58230, 381139, 78045, 99308, 160454], + [ 89135, 80552, 152558, 497981, 603535], + [ 78415, 81858, 150656, 193263, 69638], + [ 139361, 331509, 343164, 781380, 52269]] columns = ('Freeze', 'Wind', 'Flood', 'Quake', 'Hail') rows = ['%d year' % x for x in (100, 50, 20, 10, 5)] diff --git a/examples/pylab_examples/tricontour_demo.py b/examples/pylab_examples/tricontour_demo.py index ab1e7a2633ba..c1126e296ea5 100644 --- a/examples/pylab_examples/tricontour_demo.py +++ b/examples/pylab_examples/tricontour_demo.py @@ -58,10 +58,10 @@ [-0.052, 1.022], [-0.052, 1.017], [-0.069, 1.010], [-0.064, 1.005], [-0.048, 1.005], [-0.031, 1.005], [-0.031, 0.996], [-0.040, 0.987], [-0.045, 0.980], [-0.052, 0.975], [-0.040, 0.973], [-0.026, 0.968], - [-0.020, 0.954], [-0.006, 0.947], [0.003, 0.935], [0.006, 0.926], - [0.005, 0.921], [0.022, 0.923], [0.033, 0.912], [0.029, 0.905], - [0.017, 0.900], [0.012, 0.895], [0.027, 0.893], [0.019, 0.886], - [0.001, 0.883], [-0.012, 0.884], [-0.029, 0.883], [-0.038, 0.879], + [-0.020, 0.954], [-0.006, 0.947], [ 0.003, 0.935], [ 0.006, 0.926], + [ 0.005, 0.921], [ 0.022, 0.923], [ 0.033, 0.912], [ 0.029, 0.905], + [ 0.017, 0.900], [ 0.012, 0.895], [ 0.027, 0.893], [ 0.019, 0.886], + [ 0.001, 0.883], [-0.012, 0.884], [-0.029, 0.883], [-0.038, 0.879], [-0.057, 0.881], [-0.062, 0.876], [-0.078, 0.876], [-0.087, 0.872], [-0.030, 0.907], [-0.007, 0.905], [-0.057, 0.916], [-0.025, 0.933], [-0.077, 0.990], [-0.059, 0.993]]) @@ -72,11 +72,11 @@ z = np.exp(-0.01*((x - x0)*(x - x0) + (y - y0)*(y - y0))) triangles = np.asarray([ - [67, 66, 1], [65, 2, 66], [1, 66, 2], [64, 2, 65], [63, 3, 64], - [60, 59, 57], [2, 64, 3], [3, 63, 4], [0, 67, 1], [62, 4, 63], - [57, 59, 56], [59, 58, 56], [61, 60, 69], [57, 69, 60], [4, 62, 68], - [6, 5, 9], [61, 68, 62], [69, 68, 61], [9, 5, 70], [6, 8, 7], - [4, 70, 5], [8, 6, 9], [56, 69, 57], [69, 56, 52], [70, 10, 9], + [67, 66, 1], [65, 2, 66], [ 1, 66, 2], [64, 2, 65], [63, 3, 64], + [60, 59, 57], [ 2, 64, 3], [ 3, 63, 4], [ 0, 67, 1], [62, 4, 63], + [57, 59, 56], [59, 58, 56], [61, 60, 69], [57, 69, 60], [ 4, 62, 68], + [ 6, 5, 9], [61, 68, 62], [69, 68, 61], [ 9, 5, 70], [ 6, 8, 7], + [ 4, 70, 5], [ 8, 6, 9], [56, 69, 57], [69, 56, 52], [70, 10, 9], [54, 53, 55], [56, 55, 53], [68, 70, 4], [52, 56, 53], [11, 10, 12], [69, 71, 68], [68, 13, 70], [10, 70, 13], [51, 50, 52], [13, 68, 71], [52, 71, 69], [12, 10, 13], [71, 52, 50], [71, 14, 13], [50, 49, 71], diff --git a/examples/pylab_examples/tripcolor_demo.py b/examples/pylab_examples/tripcolor_demo.py index d75e6d3ad8f5..03e467c2a6d7 100644 --- a/examples/pylab_examples/tripcolor_demo.py +++ b/examples/pylab_examples/tripcolor_demo.py @@ -65,10 +65,10 @@ [-0.052, 1.022], [-0.052, 1.017], [-0.069, 1.010], [-0.064, 1.005], [-0.048, 1.005], [-0.031, 1.005], [-0.031, 0.996], [-0.040, 0.987], [-0.045, 0.980], [-0.052, 0.975], [-0.040, 0.973], [-0.026, 0.968], - [-0.020, 0.954], [-0.006, 0.947], [0.003, 0.935], [0.006, 0.926], - [0.005, 0.921], [0.022, 0.923], [0.033, 0.912], [0.029, 0.905], - [0.017, 0.900], [0.012, 0.895], [0.027, 0.893], [0.019, 0.886], - [0.001, 0.883], [-0.012, 0.884], [-0.029, 0.883], [-0.038, 0.879], + [-0.020, 0.954], [-0.006, 0.947], [ 0.003, 0.935], [ 0.006, 0.926], + [ 0.005, 0.921], [ 0.022, 0.923], [ 0.033, 0.912], [ 0.029, 0.905], + [ 0.017, 0.900], [ 0.012, 0.895], [ 0.027, 0.893], [ 0.019, 0.886], + [ 0.001, 0.883], [-0.012, 0.884], [-0.029, 0.883], [-0.038, 0.879], [-0.057, 0.881], [-0.062, 0.876], [-0.078, 0.876], [-0.087, 0.872], [-0.030, 0.907], [-0.007, 0.905], [-0.057, 0.916], [-0.025, 0.933], [-0.077, 0.990], [-0.059, 0.993]]) @@ -76,11 +76,11 @@ y = xy[:, 1]*180/3.14159 triangles = np.asarray([ - [67, 66, 1], [65, 2, 66], [1, 66, 2], [64, 2, 65], [63, 3, 64], - [60, 59, 57], [2, 64, 3], [3, 63, 4], [0, 67, 1], [62, 4, 63], - [57, 59, 56], [59, 58, 56], [61, 60, 69], [57, 69, 60], [4, 62, 68], - [6, 5, 9], [61, 68, 62], [69, 68, 61], [9, 5, 70], [6, 8, 7], - [4, 70, 5], [8, 6, 9], [56, 69, 57], [69, 56, 52], [70, 10, 9], + [67, 66, 1], [65, 2, 66], [ 1, 66, 2], [64, 2, 65], [63, 3, 64], + [60, 59, 57], [ 2, 64, 3], [ 3, 63, 4], [ 0, 67, 1], [62, 4, 63], + [57, 59, 56], [59, 58, 56], [61, 60, 69], [57, 69, 60], [ 4, 62, 68], + [ 6, 5, 9], [61, 68, 62], [69, 68, 61], [ 9, 5, 70], [ 6, 8, 7], + [ 4, 70, 5], [ 8, 6, 9], [56, 69, 57], [69, 56, 52], [70, 10, 9], [54, 53, 55], [56, 55, 53], [68, 70, 4], [52, 56, 53], [11, 10, 12], [69, 71, 68], [68, 13, 70], [10, 70, 13], [51, 50, 52], [13, 68, 71], [52, 71, 69], [12, 10, 13], [71, 52, 50], [71, 14, 13], [50, 49, 71], diff --git a/examples/pylab_examples/triplot_demo.py b/examples/pylab_examples/triplot_demo.py index 3c030fbac45e..84dcb4a76b02 100644 --- a/examples/pylab_examples/triplot_demo.py +++ b/examples/pylab_examples/triplot_demo.py @@ -56,10 +56,10 @@ [-0.052, 1.022], [-0.052, 1.017], [-0.069, 1.010], [-0.064, 1.005], [-0.048, 1.005], [-0.031, 1.005], [-0.031, 0.996], [-0.040, 0.987], [-0.045, 0.980], [-0.052, 0.975], [-0.040, 0.973], [-0.026, 0.968], - [-0.020, 0.954], [-0.006, 0.947], [0.003, 0.935], [0.006, 0.926], - [0.005, 0.921], [0.022, 0.923], [0.033, 0.912], [0.029, 0.905], - [0.017, 0.900], [0.012, 0.895], [0.027, 0.893], [0.019, 0.886], - [0.001, 0.883], [-0.012, 0.884], [-0.029, 0.883], [-0.038, 0.879], + [-0.020, 0.954], [-0.006, 0.947], [ 0.003, 0.935], [ 0.006, 0.926], + [ 0.005, 0.921], [ 0.022, 0.923], [ 0.033, 0.912], [ 0.029, 0.905], + [ 0.017, 0.900], [ 0.012, 0.895], [ 0.027, 0.893], [ 0.019, 0.886], + [ 0.001, 0.883], [-0.012, 0.884], [-0.029, 0.883], [-0.038, 0.879], [-0.057, 0.881], [-0.062, 0.876], [-0.078, 0.876], [-0.087, 0.872], [-0.030, 0.907], [-0.007, 0.905], [-0.057, 0.916], [-0.025, 0.933], [-0.077, 0.990], [-0.059, 0.993]]) @@ -67,11 +67,11 @@ y = xy[:, 1]*180/3.14159 triangles = np.asarray([ - [67, 66, 1], [65, 2, 66], [1, 66, 2], [64, 2, 65], [63, 3, 64], - [60, 59, 57], [2, 64, 3], [3, 63, 4], [0, 67, 1], [62, 4, 63], - [57, 59, 56], [59, 58, 56], [61, 60, 69], [57, 69, 60], [4, 62, 68], - [6, 5, 9], [61, 68, 62], [69, 68, 61], [9, 5, 70], [6, 8, 7], - [4, 70, 5], [8, 6, 9], [56, 69, 57], [69, 56, 52], [70, 10, 9], + [67, 66, 1], [65, 2, 66], [ 1, 66, 2], [64, 2, 65], [63, 3, 64], + [60, 59, 57], [ 2, 64, 3], [ 3, 63, 4], [ 0, 67, 1], [62, 4, 63], + [57, 59, 56], [59, 58, 56], [61, 60, 69], [57, 69, 60], [ 4, 62, 68], + [ 6, 5, 9], [61, 68, 62], [69, 68, 61], [ 9, 5, 70], [ 6, 8, 7], + [ 4, 70, 5], [ 8, 6, 9], [56, 69, 57], [69, 56, 52], [70, 10, 9], [54, 53, 55], [56, 55, 53], [68, 70, 4], [52, 56, 53], [11, 10, 12], [69, 71, 68], [68, 13, 70], [10, 70, 13], [51, 50, 52], [13, 68, 71], [52, 71, 69], [12, 10, 13], [71, 52, 50], [71, 14, 13], [50, 49, 71], diff --git a/examples/shapes_and_collections/artist_reference.py b/examples/shapes_and_collections/artist_reference.py index 1771ebfdcc65..fc22645c642c 100644 --- a/examples/shapes_and_collections/artist_reference.py +++ b/examples/shapes_and_collections/artist_reference.py @@ -63,15 +63,15 @@ def label(xy, text): # add a path patch Path = mpath.Path path_data = [ - (Path.MOVETO, [0.018, -0.110]), - (Path.CURVE4, [-0.031, -0.051]), - (Path.CURVE4, [-0.115, 0.073]), - (Path.CURVE4, [-0.030, 0.073]), - (Path.LINETO, [-0.011, 0.039]), - (Path.CURVE4, [0.043, 0.121]), - (Path.CURVE4, [0.075, -0.005]), - (Path.CURVE4, [0.035, -0.027]), - (Path.CLOSEPOLY, [0.018, -0.110]) + (Path.MOVETO, [0.018, -0.11]), + (Path.CURVE4, [-0.031, -0.051]), + (Path.CURVE4, [-0.115, 0.073]), + (Path.CURVE4, [-0.03 , 0.073]), + (Path.LINETO, [-0.011, 0.039]), + (Path.CURVE4, [0.043, 0.121]), + (Path.CURVE4, [0.075, -0.005]), + (Path.CURVE4, [0.035, -0.027]), + (Path.CLOSEPOLY, [0.018, -0.11]) ] codes, verts = zip(*path_data) path = mpath.Path(verts + grid[6], codes) From a79053c9c30cee938bd7aeebbbbcf67f43e4a354 Mon Sep 17 00:00:00 2001 From: Thomas Hisch Date: Sat, 15 Nov 2014 13:58:40 +0100 Subject: [PATCH 23/26] fix pep8 unit tests --- lib/matplotlib/tests/test_coding_standards.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/lib/matplotlib/tests/test_coding_standards.py b/lib/matplotlib/tests/test_coding_standards.py index d8d5ba353d29..59413cadea47 100644 --- a/lib/matplotlib/tests/test_coding_standards.py +++ b/lib/matplotlib/tests/test_coding_standards.py @@ -273,11 +273,16 @@ def test_pep8_conformance_examples(): exdir = os.path.join(mpldir, 'examples') blacklist = () + expected_bad_files = ['*/pylab_examples/table_demo.py', + '*/pylab_examples/tricontour_demo.py', + '*/pylab_examples/tripcolor_demo.py', + '*/pylab_examples/triplot_demo.py', + '*/shapes_and_collections/artist_reference.py'] assert_pep8_conformance(dirname=exdir, extra_exclude_directories=blacklist, pep8_additional_ignore=PEP8_ADDITIONAL_IGNORE + ['E116', 'E501'], - expected_bad_files=()) + expected_bad_files=expected_bad_files) if __name__ == '__main__': From 9591cb80baf8a5b5858fe589c0869af8e26ca3f1 Mon Sep 17 00:00:00 2001 From: Thomas Hisch Date: Sat, 15 Nov 2014 14:02:51 +0100 Subject: [PATCH 24/26] minor cleanup in pipong example (0 + value) --- examples/event_handling/pipong.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/examples/event_handling/pipong.py b/examples/event_handling/pipong.py index 51c587145b4f..770db720ff61 100755 --- a/examples/event_handling/pipong.py +++ b/examples/event_handling/pipong.py @@ -79,8 +79,9 @@ def update(self, pads): self.vx *= 1.2 * pad.signx self.vy *= 1.2 * pad.signy fudge = .001 - # probably cleaner with something like...if not self.field.contains(self.x, self.y): - if self.x < 0 + fudge: + # probably cleaner with something like... + #if not self.field.contains(self.x, self.y): + if self.x < fudge: #print("player A loses") pads[1].score += 1 self._reset(pads[0]) From eab5b5235d8eb36d6c2c99eb870f8938ac93d5cf Mon Sep 17 00:00:00 2001 From: Thomas Hisch Date: Sat, 15 Nov 2014 16:18:05 +0100 Subject: [PATCH 25/26] fixed extraneous whitespace --- examples/pylab_examples/line_collection2.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/pylab_examples/line_collection2.py b/examples/pylab_examples/line_collection2.py index 9f09a9fa8089..dc9ad04cac0c 100644 --- a/examples/pylab_examples/line_collection2.py +++ b/examples/pylab_examples/line_collection2.py @@ -23,7 +23,7 @@ # See matplotlib.collections.LineCollection for more information line_segments = LineCollection([list(zip(x, y)) for y in ys], # Make a sequence of x,y pairs linewidths=(0.5, 1, 1.5, 2), - linestyles = 'solid') + linestyles='solid') line_segments.set_array(x) ax.add_collection(line_segments) fig = gcf() From 2303939504e02e4a6424e605954bb3b53d1a0c08 Mon Sep 17 00:00:00 2001 From: Thomas Hisch Date: Sat, 15 Nov 2014 23:10:41 +0100 Subject: [PATCH 26/26] fix pep8 violations in the new boxplot examples --- examples/statistics/boxplot_color_demo.py | 31 +++++++++---------- examples/statistics/boxplot_vs_violin_demo.py | 21 ++++++------- 2 files changed, 23 insertions(+), 29 deletions(-) diff --git a/examples/statistics/boxplot_color_demo.py b/examples/statistics/boxplot_color_demo.py index cc1a9f5d6b58..e16bf3822ea2 100644 --- a/examples/statistics/boxplot_color_demo.py +++ b/examples/statistics/boxplot_color_demo.py @@ -7,18 +7,18 @@ np.random.seed(123) all_data = [np.random.normal(0, std, 100) for std in range(1, 4)] -fig, axes = plt.subplots(nrows=1,ncols=2, figsize=(12,5)) +fig, axes = plt.subplots(nrows=1, ncols=2, figsize=(12, 5)) # rectangular box plot -bplot1 = axes[0].boxplot(all_data, - vert=True, # vertical box aligmnent - patch_artist=True) # fill with color - +bplot1 = axes[0].boxplot(all_data, + vert=True, # vertical box aligmnent + patch_artist=True) # fill with color + # notch shape box plot -bplot2 = axes[1].boxplot(all_data, - notch=True, # notch shape - vert=True, # vertical box aligmnent - patch_artist=True) # fill with color +bplot2 = axes[1].boxplot(all_data, + notch=True, # notch shape + vert=True, # vertical box aligmnent + patch_artist=True) # fill with color # fill with colors colors = ['pink', 'lightblue', 'lightgreen'] @@ -26,18 +26,15 @@ for patch, color in zip(bplot['boxes'], colors): patch.set_facecolor(color) -# adding horizontal grid lines +# adding horizontal grid lines for ax in axes: - ax.yaxis.grid(True) + ax.yaxis.grid(True) ax.set_xticks([y+1 for y in range(len(all_data))], ) ax.set_xlabel('xlabel') ax.set_ylabel('ylabel') - + # add x-tick labels -plt.setp(axes, xticks=[y+1 for y in range(len(all_data))], - xticklabels=['x1', 'x2', 'x3', 'x4'], - ) +plt.setp(axes, xticks=[y+1 for y in range(len(all_data))], + xticklabels=['x1', 'x2', 'x3', 'x4']) plt.show() - - diff --git a/examples/statistics/boxplot_vs_violin_demo.py b/examples/statistics/boxplot_vs_violin_demo.py index b2a654828a25..acec4f00ceb5 100644 --- a/examples/statistics/boxplot_vs_violin_demo.py +++ b/examples/statistics/boxplot_vs_violin_demo.py @@ -11,32 +11,29 @@ import matplotlib.pyplot as plt import numpy as np -fig, axes = plt.subplots(nrows=1,ncols=2, figsize=(12,5)) +fig, axes = plt.subplots(nrows=1, ncols=2, figsize=(12, 5)) # generate some random test data all_data = [np.random.normal(0, std, 100) for std in range(6, 10)] # plot violin plot axes[0].violinplot(all_data, - showmeans=False, - showmedians=True - ) + showmeans=False, + showmedians=True) axes[0].set_title('violin plot') # plot box plot axes[1].boxplot(all_data) axes[1].set_title('box plot') -# adding horizontal grid lines +# adding horizontal grid lines for ax in axes: - ax.yaxis.grid(True) - ax.set_xticks([y+1 for y in range(len(all_data))], ) + ax.yaxis.grid(True) + ax.set_xticks([y+1 for y in range(len(all_data))]) ax.set_xlabel('xlabel') ax.set_ylabel('ylabel') # add x-tick labels -plt.setp(axes, xticks=[y+1 for y in range(len(all_data))], - xticklabels=['x1', 'x2', 'x3', 'x4'], - ) - -plt.show() \ No newline at end of file +plt.setp(axes, xticks=[y+1 for y in range(len(all_data))], + xticklabels=['x1', 'x2', 'x3', 'x4']) +plt.show()