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 aa2581fc5406..e6bff2ca11cf 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 adb23cca4215..495d674a3e00 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 2bbad25ac467..f439344eb41a 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 similarity index 100% rename from examples/pylab_examples/contour_demo.py rename to 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 similarity index 91% rename from examples/pylab_examples/contour_image.py rename to examples/images_contours_and_fields/contour_image.py index 8d0c8092a71f..db66a482e356 100644 --- a/examples/pylab_examples/contour_image.py +++ b/examples/images_contours_and_fields/contour_image.py @@ -28,7 +28,8 @@ 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 @@ 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 @@ # 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 similarity index 99% rename from examples/pylab_examples/contour_label_demo.py rename to examples/images_contours_and_fields/contour_label_demo.py index 0a32bf738fa4..296804055c1a 100644 --- a/examples/pylab_examples/contour_label_demo.py +++ b/examples/images_contours_and_fields/contour_label_demo.py @@ -48,6 +48,7 @@ def __repr__(self): 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 similarity index 89% rename from examples/pylab_examples/contourf_demo.py rename to examples/images_contours_and_fields/contourf_demo.py index fe90a80f1a69..496a8b321564 100644 --- a/examples/pylab_examples/contourf_demo.py +++ b/examples/images_contours_and_fields/contourf_demo.py @@ -8,7 +8,6 @@ import matplotlib.pyplot as plt origin = 'lower' -#origin = 'upper' delta = 0.025 @@ -21,13 +20,13 @@ 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 @@ # 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 similarity index 100% rename from examples/pylab_examples/contourf_hatching.py rename to 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 similarity index 100% rename from examples/pylab_examples/figimage_demo.py rename to 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 similarity index 100% rename from examples/pylab_examples/griddata_demo.py rename to 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 similarity index 94% rename from examples/pylab_examples/layer_images.py rename to examples/images_contours_and_fields/layer_images.py index ed92707de88c..725876045924 100644 --- a/examples/pylab_examples/layer_images.py +++ b/examples/images_contours_and_fields/layer_images.py @@ -11,7 +11,8 @@ 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 similarity index 97% rename from examples/pylab_examples/multi_image.py rename to examples/images_contours_and_fields/multi_image.py index 70b62a54ce1e..41781db406cb 100644 --- a/examples/pylab_examples/multi_image.py +++ b/examples/images_contours_and_fields/multi_image.py @@ -34,7 +34,7 @@ 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 @@ def __call__(self, leader): 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 similarity index 95% rename from examples/pylab_examples/pcolor_demo.py rename to examples/images_contours_and_fields/pcolor_demo.py index ce56253dbef0..f765de2c7fa6 100644 --- a/examples/pylab_examples/pcolor_demo.py +++ b/examples/images_contours_and_fields/pcolor_demo.py @@ -28,6 +28,7 @@ c = ax1.pcolor(Z, edgecolors='k', linewidths=4) ax1.set_title('thick edges') +fig.tight_layout() plt.show() ############################################################################### @@ -94,7 +95,8 @@ # 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 similarity index 94% rename from examples/pylab_examples/quadmesh_demo.py rename to examples/images_contours_and_fields/quadmesh_demo.py index e26125edeafd..1728b63f4a7f 100644 --- a/examples/pylab_examples/quadmesh_demo.py +++ b/examples/images_contours_and_fields/quadmesh_demo.py @@ -16,12 +16,12 @@ 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 similarity index 100% rename from examples/pylab_examples/quiver_demo.py rename to 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 similarity index 100% rename from examples/pylab_examples/quiver_simple_demo.py rename to 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 similarity index 99% rename from examples/pylab_examples/shading_example.py rename to examples/images_contours_and_fields/shading_example.py index eca4badb6b97..02bbd4ed0e14 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 similarity index 92% rename from examples/pylab_examples/tricontour_demo.py rename to examples/images_contours_and_fields/tricontour_demo.py index 75a4cf4f3dca..53e0a0bff9b7 100644 --- a/examples/pylab_examples/tricontour_demo.py +++ b/examples/images_contours_and_fields/tricontour_demo.py @@ -19,13 +19,13 @@ 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 @@ # 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 @@ 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 similarity index 94% rename from examples/pylab_examples/tricontour_smooth_delaunay.py rename to examples/images_contours_and_fields/tricontour_smooth_delaunay.py index 505e95d53f1a..b95be3a23008 100644 --- a/examples/pylab_examples/tricontour_smooth_delaunay.py +++ b/examples/images_contours_and_fields/tricontour_smooth_delaunay.py @@ -35,15 +35,15 @@ #----------------------------------------------------------------------------- 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 @@ def experiment_res(x, y): # 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 similarity index 83% rename from examples/pylab_examples/tricontour_smooth_user.py rename to examples/images_contours_and_fields/tricontour_smooth_user.py index 90eeb67bee38..2523fc18d7e7 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 @@ def function_z(x, y): 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 @@ def function_z(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 similarity index 87% rename from examples/pylab_examples/tricontour_vs_griddata.py rename to examples/images_contours_and_fields/tricontour_vs_griddata.py index 7ae6bbf84893..42d1065005d0 100644 --- a/examples/pylab_examples/tricontour_vs_griddata.py +++ b/examples/images_contours_and_fields/tricontour_vs_griddata.py @@ -18,7 +18,7 @@ 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.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.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 similarity index 100% rename from examples/pylab_examples/trigradient_demo.py rename to 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 similarity index 97% rename from examples/pylab_examples/triinterp_demo.py rename to examples/images_contours_and_fields/triinterp_demo.py index 8e9ed48cf559..9f8dacf0520f 100644 --- a/examples/pylab_examples/triinterp_demo.py +++ b/examples/images_contours_and_fields/triinterp_demo.py @@ -17,7 +17,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 similarity index 91% rename from examples/pylab_examples/tripcolor_demo.py rename to examples/images_contours_and_fields/tripcolor_demo.py index 41928439949d..be6f70432089 100644 --- a/examples/pylab_examples/tripcolor_demo.py +++ b/examples/images_contours_and_fields/tripcolor_demo.py @@ -19,13 +19,13 @@ 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 @@ # 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 @@ 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 similarity index 94% rename from examples/pylab_examples/triplot_demo.py rename to examples/images_contours_and_fields/triplot_demo.py index f41e46f07df9..897b1bc50874 100644 --- a/examples/pylab_examples/triplot_demo.py +++ b/examples/images_contours_and_fields/triplot_demo.py @@ -19,12 +19,12 @@ 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 @@ # 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 f2adae576833..a2cdc0c95ae0 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