diff options
author | Nelle Varoquaux <nelle.varoquaux@gmail.com> | 2017-07-15 15:57:37 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-07-15 15:57:37 -0700 |
commit | c0cd944cc456a061ce1deb8d46aa4514b72092af (patch) | |
tree | adf1348cbf11254c8d4293b8183beb7214c71bf8 | |
parent | 87638e31678569f698c8222d5d3389ad7568ac39 (diff) | |
parent | d4021aa5797111e74c2fdcc51d507f4ab3626360 (diff) |
Merge pull request #8858 from dstansby/pylab-moves3
Pylab example moves 3
-rw-r--r-- | doc/users/prev_whats_new/whats_new_1.0.rst | 4 | ||||
-rw-r--r-- | doc/users/prev_whats_new/whats_new_1.2.rst | 13 | ||||
-rw-r--r-- | doc/users/prev_whats_new/whats_new_1.3.rst | 10 | ||||
-rw-r--r-- | examples/images_contours_and_fields/contour_demo.py (renamed from examples/pylab_examples/contour_demo.py) | 0 | ||||
-rw-r--r-- | examples/images_contours_and_fields/contour_image.py (renamed from examples/pylab_examples/contour_image.py) | 10 | ||||
-rw-r--r-- | examples/images_contours_and_fields/contour_label_demo.py (renamed from examples/pylab_examples/contour_label_demo.py) | 1 | ||||
-rw-r--r-- | examples/images_contours_and_fields/contourf_demo.py (renamed from examples/pylab_examples/contourf_demo.py) | 15 | ||||
-rw-r--r-- | examples/images_contours_and_fields/contourf_hatching.py (renamed from examples/pylab_examples/contourf_hatching.py) | 0 | ||||
-rw-r--r-- | examples/images_contours_and_fields/figimage_demo.py (renamed from examples/pylab_examples/figimage_demo.py) | 0 | ||||
-rw-r--r-- | examples/images_contours_and_fields/griddata_demo.py (renamed from examples/pylab_examples/griddata_demo.py) | 0 | ||||
-rw-r--r-- | examples/images_contours_and_fields/layer_images.py (renamed from examples/pylab_examples/layer_images.py) | 3 | ||||
-rw-r--r-- | examples/images_contours_and_fields/multi_image.py (renamed from examples/pylab_examples/multi_image.py) | 3 | ||||
-rw-r--r-- | examples/images_contours_and_fields/pcolor_demo.py (renamed from examples/pylab_examples/pcolor_demo.py) | 4 | ||||
-rw-r--r-- | examples/images_contours_and_fields/quadmesh_demo.py (renamed from examples/pylab_examples/quadmesh_demo.py) | 4 | ||||
-rw-r--r-- | examples/images_contours_and_fields/quiver_demo.py (renamed from examples/pylab_examples/quiver_demo.py) | 0 | ||||
-rw-r--r-- | examples/images_contours_and_fields/quiver_simple_demo.py (renamed from examples/pylab_examples/quiver_simple_demo.py) | 0 | ||||
-rw-r--r-- | examples/images_contours_and_fields/shading_example.py (renamed from examples/pylab_examples/shading_example.py) | 1 | ||||
-rw-r--r-- | examples/images_contours_and_fields/tricontour_demo.py (renamed from examples/pylab_examples/tricontour_demo.py) | 14 | ||||
-rw-r--r-- | examples/images_contours_and_fields/tricontour_smooth_delaunay.py (renamed from examples/pylab_examples/tricontour_smooth_delaunay.py) | 12 | ||||
-rw-r--r-- | examples/images_contours_and_fields/tricontour_smooth_user.py (renamed from examples/pylab_examples/tricontour_smooth_user.py) | 18 | ||||
-rw-r--r-- | examples/images_contours_and_fields/tricontour_vs_griddata.py (renamed from examples/pylab_examples/tricontour_vs_griddata.py) | 8 | ||||
-rw-r--r-- | examples/images_contours_and_fields/trigradient_demo.py (renamed from examples/pylab_examples/trigradient_demo.py) | 0 | ||||
-rw-r--r-- | examples/images_contours_and_fields/triinterp_demo.py (renamed from examples/pylab_examples/triinterp_demo.py) | 2 | ||||
-rw-r--r-- | examples/images_contours_and_fields/tripcolor_demo.py (renamed from examples/pylab_examples/tripcolor_demo.py) | 15 | ||||
-rw-r--r-- | examples/images_contours_and_fields/triplot_demo.py (renamed from examples/pylab_examples/triplot_demo.py) | 10 | ||||
-rw-r--r-- | pytest.ini | 8 |
26 files changed, 72 insertions, 83 deletions
diff --git a/doc/users/prev_whats_new/whats_new_1.0.rst b/doc/users/prev_whats_new/whats_new_1.0.rst index aa2581fc5..e6bff2ca1 100644 --- a/doc/users/prev_whats_new/whats_new_1.0.rst +++ b/doc/users/prev_whats_new/whats_new_1.0.rst @@ -58,8 +58,8 @@ Additionally, he has contributed a new module :mod:`~matplotlib.tri` and helper function :func:`~matplotlib.pyplot.triplot` for creating and plotting unstructured triangular grids. -.. figure:: ../../gallery/pylab_examples/images/sphx_glr_triplot_demo_001.png - :target: ../../gallery/pylab_examples/triplot_demo.html +.. figure:: ../../gallery/images_contours_and_fields/images/sphx_glr_triplot_demo_001.png + :target: ../../gallery/images_contours_and_fields/triplot_demo.html :align: center :scale: 50 diff --git a/doc/users/prev_whats_new/whats_new_1.2.rst b/doc/users/prev_whats_new/whats_new_1.2.rst index adb23cca4..495d674a3 100644 --- a/doc/users/prev_whats_new/whats_new_1.2.rst +++ b/doc/users/prev_whats_new/whats_new_1.2.rst @@ -200,8 +200,8 @@ Ian Thomas extended :meth:`~matplotlib.pyplot.tripcolor` to allow one color value to be specified for each triangular face rather than for each point in a triangulation. -.. figure:: ../../gallery/pylab_examples/images/sphx_glr_tripcolor_demo_001.png - :target: ../../gallery/pylab_examples/tripcolor_demo.html +.. figure:: ../../gallery/images_contours_and_fields/images/sphx_glr_tripcolor_demo_001.png + :target: ../../gallery/images_contours_and_fields/tripcolor_demo.html :align: center :scale: 50 @@ -214,8 +214,8 @@ Phil Elson added support for hatching to :func:`~matplotlib.pyplot.contourf`, together with the ability to use a legend to identify contoured ranges. -.. figure:: ../../gallery/pylab_examples/images/sphx_glr_contourf_hatching_001.png - :target: ../../gallery/pylab_examples/contourf_hatching.html +.. figure:: ../../gallery/images_contours_and_fields/images/sphx_glr_contourf_hatching_001.png + :target: ../../gallery/images_contours_and_fields/contourf_hatching.html :align: center :scale: 50 @@ -227,8 +227,3 @@ Known issues in the matplotlib 1.2 release - When using the Qt4Agg backend with IPython 0.11 or later, the save dialog will not display. This should be fixed in a future version of IPython. - - - - - diff --git a/doc/users/prev_whats_new/whats_new_1.3.rst b/doc/users/prev_whats_new/whats_new_1.3.rst index 2bbad25ac..f439344eb 100644 --- a/doc/users/prev_whats_new/whats_new_1.3.rst +++ b/doc/users/prev_whats_new/whats_new_1.3.rst @@ -141,8 +141,8 @@ perform mesh refinement and smooth contouring was also added implementing some basic tools for triangular mesh improvement was added (:class:`~matplotlib.tri.TriAnalyzer`). -.. figure:: ../../gallery/pylab_examples/images/sphx_glr_tricontour_smooth_user_001.png - :target: ../../gallery/pylab_examples/tricontour_smooth_user.html +.. figure:: ../../gallery/images_contours_and_fields/images/sphx_glr_tricontour_smooth_user_001.png + :target: ../../gallery/images_contours_and_fields/tricontour_smooth_user.html :align: center :scale: 50 @@ -400,9 +400,3 @@ matplotlib will now display a `RuntimeWarning` when too many figures have been opened at once. By default, this is displayed for 20 or more figures, but the exact number may be controlled using the ``figure.max_open_warning`` rcParam. - - - - - - diff --git a/examples/pylab_examples/contour_demo.py b/examples/images_contours_and_fields/contour_demo.py index 150de3f09..150de3f09 100644 --- a/examples/pylab_examples/contour_demo.py +++ b/examples/images_contours_and_fields/contour_demo.py diff --git a/examples/pylab_examples/contour_image.py b/examples/images_contours_and_fields/contour_image.py index 8d0c8092a..db66a482e 100644 --- a/examples/pylab_examples/contour_image.py +++ b/examples/images_contours_and_fields/contour_image.py @@ -28,7 +28,8 @@ 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 = (Z1 - Z2) * 10 -levels = np.arange(-2.0, 1.601, 0.4) # Boost the upper limit to avoid truncation errors. +# Boost the upper limit to avoid truncation errors. +levels = np.arange(-2.0, 1.601, 0.4) norm = cm.colors.Normalize(vmax=abs(Z).max(), vmin=-abs(Z).max()) cmap = cm.PRGn @@ -40,9 +41,7 @@ fig.subplots_adjust(hspace=0.3) plt.subplot(2, 2, 1) cset1 = plt.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). @@ -94,7 +93,8 @@ plt.subplot(2, 2, 4) # This is intentional. The Z values are defined at the center of each # image pixel (each color block on the following subplot), so the # domain that is contoured does not extend beyond these pixel centers. -im = plt.imshow(Z, interpolation='nearest', extent=extent, cmap=cmap, norm=norm) +im = plt.imshow(Z, interpolation='nearest', extent=extent, + cmap=cmap, norm=norm) v = plt.axis() plt.contour(Z, levels, colors='k', origin='image', extent=extent) plt.axis(v) diff --git a/examples/pylab_examples/contour_label_demo.py b/examples/images_contours_and_fields/contour_label_demo.py index 0a32bf738..296804055 100644 --- a/examples/pylab_examples/contour_label_demo.py +++ b/examples/images_contours_and_fields/contour_label_demo.py @@ -48,6 +48,7 @@ class nf(float): else: return '%.1f' % self.__float__() + # Recast levels to new class CS.levels = [nf(val) for val in CS.levels] diff --git a/examples/pylab_examples/contourf_demo.py b/examples/images_contours_and_fields/contourf_demo.py index fe90a80f1..496a8b321 100644 --- a/examples/pylab_examples/contourf_demo.py +++ b/examples/images_contours_and_fields/contourf_demo.py @@ -8,7 +8,6 @@ import numpy as np import matplotlib.pyplot as plt origin = 'lower' -#origin = 'upper' delta = 0.025 @@ -21,13 +20,13 @@ Z = 10 * (Z1 - Z2) nr, nc = Z.shape # put NaNs in one corner: -Z[-nr//6:, -nc//6:] = np.nan +Z[-nr // 6:, -nc // 6:] = np.nan # contourf will convert these to masked Z = np.ma.array(Z) # mask another corner: -Z[:nr//6, :nc//6] = np.ma.masked +Z[:nr // 6, :nc // 6] = np.ma.masked # mask a circle in the middle: interior = np.sqrt((X**2) + (Y**2)) < 0.5 @@ -37,20 +36,14 @@ Z[interior] = np.ma.masked # this is usually not such a good idea, because they don't # occur on nice boundaries, but we do it here for purposes # of illustration. -CS = plt.contourf(X, Y, Z, 10, - #[-1, -0.1, 0, 0.1], - #alpha=0.5, - cmap=plt.cm.bone, - origin=origin) +CS = plt.contourf(X, Y, Z, 10, cmap=plt.cm.bone, origin=origin) # Note that in the following, we explicitly pass in a subset of # the contour levels used for the filled contours. Alternatively, # We could pass in additional levels to provide extra resolution, # 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) +CS2 = plt.contour(CS, levels=CS.levels[::2], colors='r', origin=origin) plt.title('Nonsense (3 masked regions)') plt.xlabel('word length anomaly') diff --git a/examples/pylab_examples/contourf_hatching.py b/examples/images_contours_and_fields/contourf_hatching.py index e28a64a88..e28a64a88 100644 --- a/examples/pylab_examples/contourf_hatching.py +++ b/examples/images_contours_and_fields/contourf_hatching.py diff --git a/examples/pylab_examples/figimage_demo.py b/examples/images_contours_and_fields/figimage_demo.py index 126c3de56..126c3de56 100644 --- a/examples/pylab_examples/figimage_demo.py +++ b/examples/images_contours_and_fields/figimage_demo.py diff --git a/examples/pylab_examples/griddata_demo.py b/examples/images_contours_and_fields/griddata_demo.py index 9312eff2f..9312eff2f 100644 --- a/examples/pylab_examples/griddata_demo.py +++ b/examples/images_contours_and_fields/griddata_demo.py diff --git a/examples/pylab_examples/layer_images.py b/examples/images_contours_and_fields/layer_images.py index ed92707de..725876045 100644 --- a/examples/pylab_examples/layer_images.py +++ b/examples/images_contours_and_fields/layer_images.py @@ -11,7 +11,8 @@ import numpy as np def func3(x, y): - return (1 - x/2 + x**5 + y**3)*np.exp(-(x**2 + y**2)) + return (1 - x / 2 + x**5 + y**3) * np.exp(-(x**2 + y**2)) + # make these smaller to increase the resolution dx, dy = 0.05, 0.05 diff --git a/examples/pylab_examples/multi_image.py b/examples/images_contours_and_fields/multi_image.py index 70b62a54c..41781db40 100644 --- a/examples/pylab_examples/multi_image.py +++ b/examples/images_contours_and_fields/multi_image.py @@ -34,7 +34,7 @@ vmin = 1e40 vmax = -1e40 for i in range(Nr): for j in range(Nc): - pos = [0.075 + j*1.1*w, 0.18 + i*1.2*h, w, h] + pos = [0.075 + j * 1.1 * w, 0.18 + i * 1.2 * h, w, h] a = fig.add_axes(pos) if i > 0: a.set_xticklabels([]) @@ -64,6 +64,7 @@ class ImageFollower(object): self.follower.set_cmap(leader.get_cmap()) self.follower.set_clim(leader.get_clim()) + norm = colors.Normalize(vmin=vmin, vmax=vmax) for i, im in enumerate(images): im.set_norm(norm) diff --git a/examples/pylab_examples/pcolor_demo.py b/examples/images_contours_and_fields/pcolor_demo.py index ce56253db..f765de2c7 100644 --- a/examples/pylab_examples/pcolor_demo.py +++ b/examples/images_contours_and_fields/pcolor_demo.py @@ -28,6 +28,7 @@ ax0.set_title('default: no edges') c = ax1.pcolor(Z, edgecolors='k', linewidths=4) ax1.set_title('thick edges') +fig.tight_layout() plt.show() ############################################################################### @@ -94,7 +95,8 @@ X, Y = np.mgrid[-3:3:complex(0, N), -2:2:complex(0, N)] # A low hump with a spike coming out of the top right. # Needs to have z/colour axis on a log scale so we see both hump and spike. # linear scale only shows the spike. -Z1 = bivariate_normal(X, Y, 0.1, 0.2, 1.0, 1.0) + 0.1 * bivariate_normal(X, Y, 1.0, 1.0, 0.0, 0.0) +Z1 = (bivariate_normal(X, Y, 0.1, 0.2, 1.0, 1.0) + + 0.1 * bivariate_normal(X, Y, 1.0, 1.0, 0.0, 0.0)) fig, (ax0, ax1) = plt.subplots(2, 1) diff --git a/examples/pylab_examples/quadmesh_demo.py b/examples/images_contours_and_fields/quadmesh_demo.py index e26125ede..1728b63f4 100644 --- a/examples/pylab_examples/quadmesh_demo.py +++ b/examples/images_contours_and_fields/quadmesh_demo.py @@ -16,12 +16,12 @@ from numpy import ma n = 12 x = np.linspace(-1.5, 1.5, n) -y = np.linspace(-1.5, 1.5, n*2) +y = np.linspace(-1.5, 1.5, n * 2) 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/quiver_demo.py b/examples/images_contours_and_fields/quiver_demo.py index 72e05698e..72e05698e 100644 --- a/examples/pylab_examples/quiver_demo.py +++ b/examples/images_contours_and_fields/quiver_demo.py diff --git a/examples/pylab_examples/quiver_simple_demo.py b/examples/images_contours_and_fields/quiver_simple_demo.py index f4df0bbcc..f4df0bbcc 100644 --- a/examples/pylab_examples/quiver_simple_demo.py +++ b/examples/images_contours_and_fields/quiver_simple_demo.py diff --git a/examples/pylab_examples/shading_example.py b/examples/images_contours_and_fields/shading_example.py index eca4badb6..02bbd4ed0 100644 --- a/examples/pylab_examples/shading_example.py +++ b/examples/images_contours_and_fields/shading_example.py @@ -59,5 +59,6 @@ def compare(z, cmap, ve=1): return fig + if __name__ == '__main__': main() diff --git a/examples/pylab_examples/tricontour_demo.py b/examples/images_contours_and_fields/tricontour_demo.py index 75a4cf4f3..53e0a0bff 100644 --- a/examples/pylab_examples/tricontour_demo.py +++ b/examples/images_contours_and_fields/tricontour_demo.py @@ -19,13 +19,13 @@ n_radii = 8 min_radius = 0.25 radii = np.linspace(min_radius, 0.95, n_radii) -angles = np.linspace(0, 2*math.pi, n_angles, endpoint=False) +angles = np.linspace(0, 2 * math.pi, n_angles, endpoint=False) angles = np.repeat(angles[..., np.newaxis], n_radii, axis=1) -angles[:, 1::2] += math.pi/n_angles +angles[:, 1::2] += math.pi / n_angles -x = (radii*np.cos(angles)).flatten() -y = (radii*np.sin(angles)).flatten() -z = (np.cos(radii)*np.cos(angles*3.0)).flatten() +x = (radii * np.cos(angles)).flatten() +y = (radii * np.sin(angles)).flatten() +z = (np.cos(radii) * np.cos(angles * 3.0)).flatten() # Create the Triangulation; no triangles so Delaunay triangulation created. triang = tri.Triangulation(x, y) @@ -33,7 +33,7 @@ triang = tri.Triangulation(x, y) # Mask off unwanted triangles. xmid = x[triang.triangles].mean(axis=1) ymid = y[triang.triangles].mean(axis=1) -mask = np.where(xmid*xmid + ymid*ymid < min_radius*min_radius, 1, 0) +mask = np.where(xmid * xmid + ymid * ymid < min_radius * min_radius, 1, 0) triang.set_mask(mask) # pcolor plot. @@ -73,7 +73,7 @@ x = np.degrees(xy[:, 0]) y = np.degrees(xy[:, 1]) 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/images_contours_and_fields/tricontour_smooth_delaunay.py index 505e95d53..b95be3a23 100644 --- a/examples/pylab_examples/tricontour_smooth_delaunay.py +++ b/examples/images_contours_and_fields/tricontour_smooth_delaunay.py @@ -35,15 +35,15 @@ import numpy as np #----------------------------------------------------------------------------- def experiment_res(x, y): """ An analytic function representing experiment results """ - x = 2.*x + 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) + - 2*(x**2 + y**2)) - return (np.max(z) - z)/(np.max(z) - np.min(z)) + 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)) #----------------------------------------------------------------------------- # Generating the initial data test points and triangulation for the demo @@ -76,7 +76,7 @@ ntri = tri.triangles.shape[0] # Some invalid data are masked out mask_init = np.zeros(ntri, dtype=np.bool) -masked_tri = random_gen.randint(0, ntri, int(ntri*init_mask_frac)) +masked_tri = random_gen.randint(0, ntri, int(ntri * init_mask_frac)) mask_init[masked_tri] = True tri.set_mask(mask_init) diff --git a/examples/pylab_examples/tricontour_smooth_user.py b/examples/images_contours_and_fields/tricontour_smooth_user.py index 90eeb67be..2523fc18d 100644 --- a/examples/pylab_examples/tricontour_smooth_user.py +++ b/examples/images_contours_and_fields/tricontour_smooth_user.py @@ -22,10 +22,10 @@ def function_z(x, y): 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)) + 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)) #----------------------------------------------------------------------------- # Creating a Triangulation @@ -36,12 +36,12 @@ n_radii = 10 min_radius = 0.15 radii = np.linspace(min_radius, 0.95, n_radii) -angles = np.linspace(0, 2*math.pi, n_angles, endpoint=False) +angles = np.linspace(0, 2 * math.pi, n_angles, endpoint=False) angles = np.repeat(angles[..., np.newaxis], n_radii, axis=1) -angles[:, 1::2] += math.pi/n_angles +angles[:, 1::2] += math.pi / n_angles -x = (radii*np.cos(angles)).flatten() -y = (radii*np.sin(angles)).flatten() +x = (radii * np.cos(angles)).flatten() +y = (radii * np.sin(angles)).flatten() z = function_z(x, y) # Now create the Triangulation. @@ -52,7 +52,7 @@ triang = tri.Triangulation(x, y) # Mask off unwanted triangles. xmid = x[triang.triangles].mean(axis=1) ymid = y[triang.triangles].mean(axis=1) -mask = np.where(xmid*xmid + ymid*ymid < min_radius*min_radius, 1, 0) +mask = np.where(xmid * xmid + ymid * ymid < min_radius * min_radius, 1, 0) triang.set_mask(mask) #----------------------------------------------------------------------------- diff --git a/examples/pylab_examples/tricontour_vs_griddata.py b/examples/images_contours_and_fields/tricontour_vs_griddata.py index 7ae6bbf84..42d106500 100644 --- a/examples/pylab_examples/tricontour_vs_griddata.py +++ b/examples/images_contours_and_fields/tricontour_vs_griddata.py @@ -18,7 +18,7 @@ ngridx = 100 ngridy = 200 x = np.random.uniform(-2, 2, npts) y = np.random.uniform(-2, 2, npts) -z = x*np.exp(-x**2 - y**2) +z = x * np.exp(-x**2 - y**2) # griddata and contour. start = time.clock() @@ -34,8 +34,8 @@ plt.plot(x, y, 'ko', ms=3) plt.xlim(-2, 2) plt.ylim(-2, 2) plt.title('griddata and contour (%d points, %d grid points)' % - (npts, ngridx*ngridy)) -print('griddata and contour seconds: %f' % (time.clock() - start)) + (npts, ngridx * ngridy)) +print('griddata and contour: %f seconds' % (time.clock() - start)) # tricontour. start = time.clock() @@ -49,7 +49,7 @@ plt.plot(x, y, 'ko', ms=3) plt.xlim(-2, 2) plt.ylim(-2, 2) plt.title('tricontour (%d points)' % npts) -print('tricontour seconds: %f' % (time.clock() - start)) +print('tricontour: %f seconds' % (time.clock() - start)) plt.subplots_adjust(hspace=0.5) diff --git a/examples/pylab_examples/trigradient_demo.py b/examples/images_contours_and_fields/trigradient_demo.py index 9470c5112..9470c5112 100644 --- a/examples/pylab_examples/trigradient_demo.py +++ b/examples/images_contours_and_fields/trigradient_demo.py diff --git a/examples/pylab_examples/triinterp_demo.py b/examples/images_contours_and_fields/triinterp_demo.py index 8e9ed48cf..9f8dacf05 100644 --- a/examples/pylab_examples/triinterp_demo.py +++ b/examples/images_contours_and_fields/triinterp_demo.py @@ -17,7 +17,7 @@ triangles = [[0, 1, 4], [1, 2, 5], [2, 3, 6], [1, 5, 4], [2, 6, 5], [4, 5, 7], triang = mtri.Triangulation(x, y, triangles) # Interpolate to regularly-spaced quad grid. -z = np.cos(1.5*x)*np.cos(1.5*y) +z = np.cos(1.5 * x) * np.cos(1.5 * y) xi, yi = np.meshgrid(np.linspace(0, 3, 20), np.linspace(0, 3, 20)) interp_lin = mtri.LinearTriInterpolator(triang, z) diff --git a/examples/pylab_examples/tripcolor_demo.py b/examples/images_contours_and_fields/tripcolor_demo.py index 419284399..be6f70432 100644 --- a/examples/pylab_examples/tripcolor_demo.py +++ b/examples/images_contours_and_fields/tripcolor_demo.py @@ -19,13 +19,13 @@ n_radii = 8 min_radius = 0.25 radii = np.linspace(min_radius, 0.95, n_radii) -angles = np.linspace(0, 2*math.pi, n_angles, endpoint=False) +angles = np.linspace(0, 2 * math.pi, n_angles, endpoint=False) angles = np.repeat(angles[..., np.newaxis], n_radii, axis=1) -angles[:, 1::2] += math.pi/n_angles +angles[:, 1::2] += math.pi / n_angles -x = (radii*np.cos(angles)).flatten() -y = (radii*np.sin(angles)).flatten() -z = (np.cos(radii)*np.cos(angles*3.0)).flatten() +x = (radii * np.cos(angles)).flatten() +y = (radii * np.sin(angles)).flatten() +z = (np.cos(radii) * np.cos(angles * 3.0)).flatten() # Create the Triangulation; no triangles so Delaunay triangulation created. triang = tri.Triangulation(x, y) @@ -33,7 +33,7 @@ triang = tri.Triangulation(x, y) # Mask off unwanted triangles. xmid = x[triang.triangles].mean(axis=1) ymid = y[triang.triangles].mean(axis=1) -mask = np.where(xmid*xmid + ymid*ymid < min_radius*min_radius, 1, 0) +mask = np.where(xmid * xmid + ymid * ymid < min_radius * min_radius, 1, 0) triang.set_mask(mask) # tripcolor plot. @@ -100,7 +100,8 @@ xmid = x[triangles].mean(axis=1) 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/triplot_demo.py b/examples/images_contours_and_fields/triplot_demo.py index f41e46f07..897b1bc50 100644 --- a/examples/pylab_examples/triplot_demo.py +++ b/examples/images_contours_and_fields/triplot_demo.py @@ -19,12 +19,12 @@ n_radii = 8 min_radius = 0.25 radii = np.linspace(min_radius, 0.95, n_radii) -angles = np.linspace(0, 2*math.pi, n_angles, endpoint=False) +angles = np.linspace(0, 2 * math.pi, n_angles, endpoint=False) angles = np.repeat(angles[..., np.newaxis], n_radii, axis=1) -angles[:, 1::2] += math.pi/n_angles +angles[:, 1::2] += math.pi / n_angles -x = (radii*np.cos(angles)).flatten() -y = (radii*np.sin(angles)).flatten() +x = (radii * np.cos(angles)).flatten() +y = (radii * np.sin(angles)).flatten() # Create the Triangulation; no triangles so Delaunay triangulation created. triang = tri.Triangulation(x, y) @@ -32,7 +32,7 @@ triang = tri.Triangulation(x, y) # Mask off unwanted triangles. xmid = x[triang.triangles].mean(axis=1) ymid = y[triang.triangles].mean(axis=1) -mask = np.where(xmid*xmid + ymid*ymid < min_radius*min_radius, 1, 0) +mask = np.where(xmid * xmid + ymid * ymid < min_radius * min_radius, 1, 0) triang.set_mask(mask) # Plot the triangulation. diff --git a/pytest.ini b/pytest.ini index f2adae576..a2cdc0c95 100644 --- a/pytest.ini +++ b/pytest.ini @@ -114,11 +114,11 @@ pep8ignore = doc/* ALL tutorials/* E402 E501 - *examples/* E116 E501 E402 + *examples/* E501 E402 *examples/pylab_examples/table_demo.py E201 - *examples/pylab_examples/tricontour_demo.py E201 - *examples/pylab_examples/tripcolor_demo.py E201 - *examples/pylab_examples/triplot_demo.py E201 + *examples/images_contours_and_fields/tricontour_demo.py E201 + *examples/images_contours_and_fields/tripcolor_demo.py E201 + *examples/images_contours_and_fields/triplot_demo.py E201 *examples/pyplots/align_ylabels.py E231 *examples/pyplots/annotate_transform.py E228 E251 *examples/pyplots/annotation_basic.py E231 |