From f99743c5494692cf14ac7400b4d8fbd8cec8e8f8 Mon Sep 17 00:00:00 2001 From: Matte Date: Mon, 24 Sep 2018 14:59:17 +0200 Subject: [PATCH] Replaced noqa-comments by using Axes3D.name instead of '3d' for projection parameters. --- examples/frontpage/3D.py | 5 ++--- examples/mplot3d/2dcollections3d.py | 5 ++--- examples/mplot3d/3d_bars.py | 7 +++---- examples/mplot3d/bars3d.py | 5 ++--- examples/mplot3d/custom_shaded_3d_surface.py | 5 ++--- examples/mplot3d/hist3d.py | 5 ++--- examples/mplot3d/lines3d.py | 5 ++--- examples/mplot3d/lorenz_attractor.py | 5 ++--- examples/mplot3d/mixed_subplots.py | 5 ++--- examples/mplot3d/offset.py | 5 ++--- examples/mplot3d/pathpatch3d.py | 5 ++--- examples/mplot3d/polys3d.py | 5 ++--- examples/mplot3d/quiver3d.py | 5 ++--- examples/mplot3d/scatter3d.py | 5 ++--- examples/mplot3d/subplot3d.py | 7 +++---- examples/mplot3d/surface3d.py | 5 ++--- examples/mplot3d/surface3d_2.py | 5 ++--- examples/mplot3d/surface3d_3.py | 5 ++--- examples/mplot3d/surface3d_radial.py | 5 ++--- examples/mplot3d/text3d.py | 5 ++--- examples/mplot3d/tricontour3d.py | 5 ++--- examples/mplot3d/tricontourf3d.py | 5 ++--- examples/mplot3d/trisurf3d.py | 5 ++--- examples/mplot3d/trisurf3d_2.py | 7 +++---- examples/mplot3d/voxels.py | 5 ++--- examples/mplot3d/voxels_numpy_logo.py | 5 ++--- examples/mplot3d/voxels_rgb.py | 5 ++--- examples/mplot3d/voxels_torus.py | 5 ++--- examples/mplot3d/wire3d_animation_sgskip.py | 5 ++--- examples/pyplots/whats_new_1_subplot3d.py | 7 +++---- 30 files changed, 64 insertions(+), 94 deletions(-) diff --git a/examples/frontpage/3D.py b/examples/frontpage/3D.py index ee93026ed06e..7829e0561912 100644 --- a/examples/frontpage/3D.py +++ b/examples/frontpage/3D.py @@ -6,8 +6,7 @@ This example reproduces the frontpage 3D example. """ -# This import registers the 3D projection, but is otherwise unused. -from mpl_toolkits.mplot3d import Axes3D # noqa: F401 unused import +from mpl_toolkits.mplot3d import Axes3D from matplotlib import cbook from matplotlib import cm @@ -26,7 +25,7 @@ region = np.s_[5:50, 5:50] x, y, z = x[region], y[region], z[region] -fig, ax = plt.subplots(subplot_kw=dict(projection='3d')) +fig, ax = plt.subplots(subplot_kw=dict(projection=Axes3D.name)) ls = LightSource(270, 45) # To use a custom hillshading mode, override the built-in shading and pass diff --git a/examples/mplot3d/2dcollections3d.py b/examples/mplot3d/2dcollections3d.py index 589e1083f7f5..78ef0d003332 100644 --- a/examples/mplot3d/2dcollections3d.py +++ b/examples/mplot3d/2dcollections3d.py @@ -7,14 +7,13 @@ selective axes of a 3D plot. """ -# This import registers the 3D projection, but is otherwise unused. -from mpl_toolkits.mplot3d import Axes3D # noqa: F401 unused import +from mpl_toolkits.mplot3d import Axes3D import numpy as np import matplotlib.pyplot as plt fig = plt.figure() -ax = fig.gca(projection='3d') +ax = fig.gca(projection=Axes3D.name) # Plot a sin curve using the x and y axes. x = np.linspace(0, 1, 100) diff --git a/examples/mplot3d/3d_bars.py b/examples/mplot3d/3d_bars.py index 483dbcc4fb71..04225f085fa0 100644 --- a/examples/mplot3d/3d_bars.py +++ b/examples/mplot3d/3d_bars.py @@ -10,14 +10,13 @@ import numpy as np import matplotlib.pyplot as plt -# This import registers the 3D projection, but is otherwise unused. -from mpl_toolkits.mplot3d import Axes3D # noqa: F401 unused import +from mpl_toolkits.mplot3d import Axes3D # setup the figure and axes fig = plt.figure(figsize=(8, 3)) -ax1 = fig.add_subplot(121, projection='3d') -ax2 = fig.add_subplot(122, projection='3d') +ax1 = fig.add_subplot(121, projection=Axes3D.name) +ax2 = fig.add_subplot(122, projection=Axes3D.name) # fake data _x = np.arange(4) diff --git a/examples/mplot3d/bars3d.py b/examples/mplot3d/bars3d.py index e30175ffac41..d2ff269c840b 100644 --- a/examples/mplot3d/bars3d.py +++ b/examples/mplot3d/bars3d.py @@ -7,8 +7,7 @@ planes y=0, y=1, etc. """ -# This import registers the 3D projection, but is otherwise unused. -from mpl_toolkits.mplot3d import Axes3D # noqa: F401 unused import +from mpl_toolkits.mplot3d import Axes3D import matplotlib.pyplot as plt import numpy as np @@ -18,7 +17,7 @@ fig = plt.figure() -ax = fig.add_subplot(111, projection='3d') +ax = fig.add_subplot(111, projection=Axes3D.name) colors = ['r', 'g', 'b', 'y'] yticks = [3, 2, 1, 0] diff --git a/examples/mplot3d/custom_shaded_3d_surface.py b/examples/mplot3d/custom_shaded_3d_surface.py index 366658856470..4d94dc6e5028 100644 --- a/examples/mplot3d/custom_shaded_3d_surface.py +++ b/examples/mplot3d/custom_shaded_3d_surface.py @@ -6,8 +6,7 @@ Demonstrates using custom hillshading in a 3D surface plot. """ -# This import registers the 3D projection, but is otherwise unused. -from mpl_toolkits.mplot3d import Axes3D # noqa: F401 unused import +from mpl_toolkits.mplot3d import Axes3D from matplotlib import cbook from matplotlib import cm @@ -28,7 +27,7 @@ x, y, z = x[region], y[region], z[region] # Set up plot -fig, ax = plt.subplots(subplot_kw=dict(projection='3d')) +fig, ax = plt.subplots(subplot_kw=dict(projection=Axes3D.name)) ls = LightSource(270, 45) # To use a custom hillshading mode, override the built-in shading and pass diff --git a/examples/mplot3d/hist3d.py b/examples/mplot3d/hist3d.py index 4cab341a64a2..8201a0265a7e 100644 --- a/examples/mplot3d/hist3d.py +++ b/examples/mplot3d/hist3d.py @@ -6,8 +6,7 @@ Demo of a histogram for 2 dimensional data as a bar graph in 3D. """ -# This import registers the 3D projection, but is otherwise unused. -from mpl_toolkits.mplot3d import Axes3D # noqa: F401 unused import +from mpl_toolkits.mplot3d import Axes3D import matplotlib.pyplot as plt import numpy as np @@ -17,7 +16,7 @@ fig = plt.figure() -ax = fig.add_subplot(111, projection='3d') +ax = fig.add_subplot(111, projection=Axes3D.name) x, y = np.random.rand(2, 100) * 4 hist, xedges, yedges = np.histogram2d(x, y, bins=4, range=[[0, 4], [0, 4]]) diff --git a/examples/mplot3d/lines3d.py b/examples/mplot3d/lines3d.py index e0e45b1c051c..b308bfd69f95 100644 --- a/examples/mplot3d/lines3d.py +++ b/examples/mplot3d/lines3d.py @@ -6,8 +6,7 @@ This example demonstrates plotting a parametric curve in 3D. ''' -# This import registers the 3D projection, but is otherwise unused. -from mpl_toolkits.mplot3d import Axes3D # noqa: F401 unused import +from mpl_toolkits.mplot3d import Axes3D import numpy as np import matplotlib.pyplot as plt @@ -16,7 +15,7 @@ plt.rcParams['legend.fontsize'] = 10 fig = plt.figure() -ax = fig.gca(projection='3d') +ax = fig.gca(projection=Axes3D.name) # Prepare arrays x, y, z theta = np.linspace(-4 * np.pi, 4 * np.pi, 100) diff --git a/examples/mplot3d/lorenz_attractor.py b/examples/mplot3d/lorenz_attractor.py index 5a1328a769d3..0fc30307ad0e 100644 --- a/examples/mplot3d/lorenz_attractor.py +++ b/examples/mplot3d/lorenz_attractor.py @@ -15,8 +15,7 @@ import numpy as np import matplotlib.pyplot as plt -# This import registers the 3D projection, but is otherwise unused. -from mpl_toolkits.mplot3d import Axes3D # noqa: F401 unused import +from mpl_toolkits.mplot3d import Axes3D def lorenz(x, y, z, s=10, r=28, b=2.667): @@ -56,7 +55,7 @@ def lorenz(x, y, z, s=10, r=28, b=2.667): # Plot fig = plt.figure() -ax = fig.gca(projection='3d') +ax = fig.gca(projection=Axes3D.name) ax.plot(xs, ys, zs, lw=0.5) ax.set_xlabel("X Axis") diff --git a/examples/mplot3d/mixed_subplots.py b/examples/mplot3d/mixed_subplots.py index 0a13715aad1b..86b28e1fd846 100644 --- a/examples/mplot3d/mixed_subplots.py +++ b/examples/mplot3d/mixed_subplots.py @@ -5,8 +5,7 @@ This example shows a how to plot a 2D and 3D plot on the same figure. """ -# This import registers the 3D projection, but is otherwise unused. -from mpl_toolkits.mplot3d import Axes3D # noqa: F401 unused import +from mpl_toolkits.mplot3d import Axes3D import matplotlib.pyplot as plt import numpy as np @@ -35,7 +34,7 @@ def f(t): ax.set_ylabel('Damped oscillation') # Second subplot -ax = fig.add_subplot(2, 1, 2, projection='3d') +ax = fig.add_subplot(2, 1, 2, projection=Axes3D.name) X = np.arange(-5, 5, 0.25) Y = np.arange(-5, 5, 0.25) diff --git a/examples/mplot3d/offset.py b/examples/mplot3d/offset.py index 04c56ed2066e..5f3f156c7896 100644 --- a/examples/mplot3d/offset.py +++ b/examples/mplot3d/offset.py @@ -13,15 +13,14 @@ automatically trigger it. ''' -# This import registers the 3D projection, but is otherwise unused. -from mpl_toolkits.mplot3d import Axes3D # noqa: F401 unused import +from mpl_toolkits.mplot3d import Axes3D import matplotlib.pyplot as plt import numpy as np fig = plt.figure() -ax = fig.gca(projection='3d') +ax = fig.gca(projection=Axes3D.name) X, Y = np.mgrid[0:6*np.pi:0.25, 0:4*np.pi:0.25] Z = np.sqrt(np.abs(np.cos(X) + np.cos(Y))) diff --git a/examples/mplot3d/pathpatch3d.py b/examples/mplot3d/pathpatch3d.py index 5976adf728a5..2b0137261317 100644 --- a/examples/mplot3d/pathpatch3d.py +++ b/examples/mplot3d/pathpatch3d.py @@ -11,8 +11,7 @@ from matplotlib.patches import Circle, PathPatch from matplotlib.text import TextPath from matplotlib.transforms import Affine2D -# This import registers the 3D projection, but is otherwise unused. -from mpl_toolkits.mplot3d import Axes3D # noqa: F401 unused import +from mpl_toolkits.mplot3d import Axes3D import mpl_toolkits.mplot3d.art3d as art3d @@ -43,7 +42,7 @@ def text3d(ax, xyz, s, zdir="z", size=None, angle=0, usetex=False, **kwargs): fig = plt.figure() -ax = fig.add_subplot(111, projection='3d') +ax = fig.add_subplot(111, projection=Axes3D.name) # Draw a circle on the x=0 'wall' p = Circle((5, 5), 3) diff --git a/examples/mplot3d/polys3d.py b/examples/mplot3d/polys3d.py index 2f7769bb784c..93c49b839478 100644 --- a/examples/mplot3d/polys3d.py +++ b/examples/mplot3d/polys3d.py @@ -8,8 +8,7 @@ of 'jagged stained glass' effect. """ -# This import registers the 3D projection, but is otherwise unused. -from mpl_toolkits.mplot3d import Axes3D # noqa: F401 unused import +from mpl_toolkits.mplot3d import Axes3D from matplotlib.collections import PolyCollection import matplotlib.pyplot as plt @@ -36,7 +35,7 @@ def polygon_under_graph(xlist, ylist): fig = plt.figure() -ax = fig.gca(projection='3d') +ax = fig.gca(projection=Axes3D.name) # Make verts a list, verts[i] will be a list of (x,y) pairs defining polygon i verts = [] diff --git a/examples/mplot3d/quiver3d.py b/examples/mplot3d/quiver3d.py index 6921b4a1d26c..9c11e828b698 100644 --- a/examples/mplot3d/quiver3d.py +++ b/examples/mplot3d/quiver3d.py @@ -6,14 +6,13 @@ Demonstrates plotting directional arrows at points on a 3d meshgrid. ''' -# This import registers the 3D projection, but is otherwise unused. -from mpl_toolkits.mplot3d import Axes3D # noqa: F401 unused import +from mpl_toolkits.mplot3d import Axes3D import matplotlib.pyplot as plt import numpy as np fig = plt.figure() -ax = fig.gca(projection='3d') +ax = fig.gca(projection=Axes3D.name) # Make the grid x, y, z = np.meshgrid(np.arange(-0.8, 1, 0.2), diff --git a/examples/mplot3d/scatter3d.py b/examples/mplot3d/scatter3d.py index d8c6a05606cd..d07c7e058928 100644 --- a/examples/mplot3d/scatter3d.py +++ b/examples/mplot3d/scatter3d.py @@ -6,8 +6,7 @@ Demonstration of a basic scatterplot in 3D. ''' -# This import registers the 3D projection, but is otherwise unused. -from mpl_toolkits.mplot3d import Axes3D # noqa: F401 unused import +from mpl_toolkits.mplot3d import Axes3D import matplotlib.pyplot as plt import numpy as np @@ -24,7 +23,7 @@ def randrange(n, vmin, vmax): return (vmax - vmin)*np.random.rand(n) + vmin fig = plt.figure() -ax = fig.add_subplot(111, projection='3d') +ax = fig.add_subplot(111, projection=Axes3D.name) n = 100 diff --git a/examples/mplot3d/subplot3d.py b/examples/mplot3d/subplot3d.py index e9c1c3f2d712..806c6aef1ea1 100644 --- a/examples/mplot3d/subplot3d.py +++ b/examples/mplot3d/subplot3d.py @@ -11,8 +11,7 @@ import numpy as np from mpl_toolkits.mplot3d.axes3d import get_test_data -# This import registers the 3D projection, but is otherwise unused. -from mpl_toolkits.mplot3d import Axes3D # noqa: F401 unused import +from mpl_toolkits.mplot3d import Axes3D # set up a figure twice as wide as it is tall @@ -22,7 +21,7 @@ # First subplot #=============== # set up the axes for the first plot -ax = fig.add_subplot(1, 2, 1, projection='3d') +ax = fig.add_subplot(1, 2, 1, projection=Axes3D.name) # plot a 3D surface like in the example mplot3d/surface3d_demo X = np.arange(-5, 5, 0.25) @@ -39,7 +38,7 @@ # Second subplot #=============== # set up the axes for the second plot -ax = fig.add_subplot(1, 2, 2, projection='3d') +ax = fig.add_subplot(1, 2, 2, projection=Axes3D.name) # plot a 3D wireframe like in the example mplot3d/wire3d_demo X, Y, Z = get_test_data(0.05) diff --git a/examples/mplot3d/surface3d.py b/examples/mplot3d/surface3d.py index eac122b6aa13..38e12e1620a8 100644 --- a/examples/mplot3d/surface3d.py +++ b/examples/mplot3d/surface3d.py @@ -10,8 +10,7 @@ z axis tick labels. ''' -# This import registers the 3D projection, but is otherwise unused. -from mpl_toolkits.mplot3d import Axes3D # noqa: F401 unused import +from mpl_toolkits.mplot3d import Axes3D import matplotlib.pyplot as plt from matplotlib import cm @@ -20,7 +19,7 @@ fig = plt.figure() -ax = fig.gca(projection='3d') +ax = fig.gca(projection=Axes3D.name) # Make data. X = np.arange(-5, 5, 0.25) diff --git a/examples/mplot3d/surface3d_2.py b/examples/mplot3d/surface3d_2.py index fe3c2fe476ea..e8156b6301ee 100644 --- a/examples/mplot3d/surface3d_2.py +++ b/examples/mplot3d/surface3d_2.py @@ -6,15 +6,14 @@ Demonstrates a very basic plot of a 3D surface using a solid color. ''' -# This import registers the 3D projection, but is otherwise unused. -from mpl_toolkits.mplot3d import Axes3D # noqa: F401 unused import +from mpl_toolkits.mplot3d import Axes3D import matplotlib.pyplot as plt import numpy as np fig = plt.figure() -ax = fig.add_subplot(111, projection='3d') +ax = fig.add_subplot(111, projection=Axes3D.name) # Make data u = np.linspace(0, 2 * np.pi, 100) diff --git a/examples/mplot3d/surface3d_3.py b/examples/mplot3d/surface3d_3.py index d75dc6680152..ec639dd7daf8 100644 --- a/examples/mplot3d/surface3d_3.py +++ b/examples/mplot3d/surface3d_3.py @@ -6,8 +6,7 @@ Demonstrates plotting a 3D surface colored in a checkerboard pattern. ''' -# This import registers the 3D projection, but is otherwise unused. -from mpl_toolkits.mplot3d import Axes3D # noqa: F401 unused import +from mpl_toolkits.mplot3d import Axes3D import matplotlib.pyplot as plt from matplotlib.ticker import LinearLocator @@ -15,7 +14,7 @@ fig = plt.figure() -ax = fig.gca(projection='3d') +ax = fig.gca(projection=Axes3D.name) # Make data. X = np.arange(-5, 5, 0.25) diff --git a/examples/mplot3d/surface3d_radial.py b/examples/mplot3d/surface3d_radial.py index 521f6195330d..9043f5048337 100644 --- a/examples/mplot3d/surface3d_radial.py +++ b/examples/mplot3d/surface3d_radial.py @@ -10,15 +10,14 @@ Example contributed by Armin Moser. ''' -# This import registers the 3D projection, but is otherwise unused. -from mpl_toolkits.mplot3d import Axes3D # noqa: F401 unused import +from mpl_toolkits.mplot3d import Axes3D import matplotlib.pyplot as plt import numpy as np fig = plt.figure() -ax = fig.add_subplot(111, projection='3d') +ax = fig.add_subplot(111, projection=Axes3D.name) # Create the mesh in polar coordinates and compute corresponding Z. r = np.linspace(0, 1.25, 50) diff --git a/examples/mplot3d/text3d.py b/examples/mplot3d/text3d.py index ed4934faf5a1..2b141c72e820 100644 --- a/examples/mplot3d/text3d.py +++ b/examples/mplot3d/text3d.py @@ -16,14 +16,13 @@ ''' -# This import registers the 3D projection, but is otherwise unused. -from mpl_toolkits.mplot3d import Axes3D # noqa: F401 unused import +from mpl_toolkits.mplot3d import Axes3D import matplotlib.pyplot as plt fig = plt.figure() -ax = fig.gca(projection='3d') +ax = fig.gca(projection=Axes3D.name) # Demo 1: zdir zdirs = (None, 'x', 'y', 'z', (1, 1, 0), (1, 1, 1)) diff --git a/examples/mplot3d/tricontour3d.py b/examples/mplot3d/tricontour3d.py index feb187cbaa16..634855ba0409 100644 --- a/examples/mplot3d/tricontour3d.py +++ b/examples/mplot3d/tricontour3d.py @@ -9,8 +9,7 @@ tricontourf3d_demo shows the filled version of this example. """ -# This import registers the 3D projection, but is otherwise unused. -from mpl_toolkits.mplot3d import Axes3D # noqa: F401 unused import +from mpl_toolkits.mplot3d import Axes3D import matplotlib.pyplot as plt import matplotlib.tri as tri @@ -39,7 +38,7 @@ < min_radius) fig = plt.figure() -ax = fig.gca(projection='3d') +ax = fig.gca(projection=Axes3D.name) ax.tricontour(triang, z, cmap=plt.cm.CMRmap) # Customize the view angle so it's easier to understand the plot. diff --git a/examples/mplot3d/tricontourf3d.py b/examples/mplot3d/tricontourf3d.py index d25b2dbd1ea5..a7a8492d0349 100644 --- a/examples/mplot3d/tricontourf3d.py +++ b/examples/mplot3d/tricontourf3d.py @@ -9,8 +9,7 @@ tricontour3d_demo shows the unfilled version of this example. """ -# This import registers the 3D projection, but is otherwise unused. -from mpl_toolkits.mplot3d import Axes3D # noqa: F401 unused import +from mpl_toolkits.mplot3d import Axes3D import matplotlib.pyplot as plt import matplotlib.tri as tri @@ -40,7 +39,7 @@ < min_radius) fig = plt.figure() -ax = fig.gca(projection='3d') +ax = fig.gca(projection=Axes3D.name) ax.tricontourf(triang, z, cmap=plt.cm.CMRmap) # Customize the view angle so it's easier to understand the plot. diff --git a/examples/mplot3d/trisurf3d.py b/examples/mplot3d/trisurf3d.py index 070a3154f2cb..4bf56fd930fd 100644 --- a/examples/mplot3d/trisurf3d.py +++ b/examples/mplot3d/trisurf3d.py @@ -6,8 +6,7 @@ Plot a 3D surface with a triangular mesh. ''' -# This import registers the 3D projection, but is otherwise unused. -from mpl_toolkits.mplot3d import Axes3D # noqa: F401 unused import +from mpl_toolkits.mplot3d import Axes3D import matplotlib.pyplot as plt import numpy as np @@ -30,7 +29,7 @@ z = np.sin(-x*y) fig = plt.figure() -ax = fig.gca(projection='3d') +ax = fig.gca(projection=Axes3D.name) ax.plot_trisurf(x, y, z, linewidth=0.2, antialiased=True) diff --git a/examples/mplot3d/trisurf3d_2.py b/examples/mplot3d/trisurf3d_2.py index b948c1b14b5d..33090fb2021d 100644 --- a/examples/mplot3d/trisurf3d_2.py +++ b/examples/mplot3d/trisurf3d_2.py @@ -14,8 +14,7 @@ import matplotlib.pyplot as plt import matplotlib.tri as mtri -# This import registers the 3D projection, but is otherwise unused. -from mpl_toolkits.mplot3d import Axes3D # noqa: F401 unused import +from mpl_toolkits.mplot3d import Axes3D fig = plt.figure(figsize=plt.figaspect(0.5)) @@ -41,7 +40,7 @@ # Plot the surface. The triangles in parameter space determine which x, y, z # points are connected by an edge. -ax = fig.add_subplot(1, 2, 1, projection='3d') +ax = fig.add_subplot(1, 2, 1, projection=Axes3D.name) ax.plot_trisurf(x, y, z, triangles=tri.triangles, cmap=plt.cm.Spectral) ax.set_zlim(-1, 1) @@ -75,7 +74,7 @@ triang.set_mask(mask) # Plot the surface. -ax = fig.add_subplot(1, 2, 2, projection='3d') +ax = fig.add_subplot(1, 2, 2, projection=Axes3D.name) ax.plot_trisurf(triang, z, cmap=plt.cm.CMRmap) diff --git a/examples/mplot3d/voxels.py b/examples/mplot3d/voxels.py index 4ba96fff6c65..a1e10d928893 100644 --- a/examples/mplot3d/voxels.py +++ b/examples/mplot3d/voxels.py @@ -9,8 +9,7 @@ import matplotlib.pyplot as plt import numpy as np -# This import registers the 3D projection, but is otherwise unused. -from mpl_toolkits.mplot3d import Axes3D # noqa: F401 unused import +from mpl_toolkits.mplot3d import Axes3D # prepare some coordinates @@ -32,7 +31,7 @@ # and plot everything fig = plt.figure() -ax = fig.gca(projection='3d') +ax = fig.gca(projection=Axes3D.name) ax.voxels(voxels, facecolors=colors, edgecolor='k') plt.show() diff --git a/examples/mplot3d/voxels_numpy_logo.py b/examples/mplot3d/voxels_numpy_logo.py index 38b00b49f4de..2a403e076f49 100644 --- a/examples/mplot3d/voxels_numpy_logo.py +++ b/examples/mplot3d/voxels_numpy_logo.py @@ -8,8 +8,7 @@ import matplotlib.pyplot as plt import numpy as np -# This import registers the 3D projection, but is otherwise unused. -from mpl_toolkits.mplot3d import Axes3D # noqa: F401 unused import +from mpl_toolkits.mplot3d import Axes3D def explode(data): @@ -43,7 +42,7 @@ def explode(data): z[:, :, 1::2] += 0.95 fig = plt.figure() -ax = fig.gca(projection='3d') +ax = fig.gca(projection=Axes3D.name) ax.voxels(x, y, z, filled_2, facecolors=fcolors_2, edgecolors=ecolors_2) plt.show() diff --git a/examples/mplot3d/voxels_rgb.py b/examples/mplot3d/voxels_rgb.py index 7b012b2a61f8..f7f899ae0e93 100644 --- a/examples/mplot3d/voxels_rgb.py +++ b/examples/mplot3d/voxels_rgb.py @@ -9,8 +9,7 @@ import matplotlib.pyplot as plt import numpy as np -# This import registers the 3D projection, but is otherwise unused. -from mpl_toolkits.mplot3d import Axes3D # noqa: F401 unused import +from mpl_toolkits.mplot3d import Axes3D def midpoints(x): @@ -37,7 +36,7 @@ def midpoints(x): # and plot everything fig = plt.figure() -ax = fig.gca(projection='3d') +ax = fig.gca(projection=Axes3D.name) ax.voxels(r, g, b, sphere, facecolors=colors, edgecolors=np.clip(2*colors - 0.5, 0, 1), # brighter diff --git a/examples/mplot3d/voxels_torus.py b/examples/mplot3d/voxels_torus.py index 3112f82792da..6483ec146ea4 100644 --- a/examples/mplot3d/voxels_torus.py +++ b/examples/mplot3d/voxels_torus.py @@ -10,8 +10,7 @@ import matplotlib.colors import numpy as np -# This import registers the 3D projection, but is otherwise unused. -from mpl_toolkits.mplot3d import Axes3D # noqa: F401 unused import +from mpl_toolkits.mplot3d import Axes3D def midpoints(x): @@ -40,7 +39,7 @@ def midpoints(x): # and plot everything fig = plt.figure() -ax = fig.gca(projection='3d') +ax = fig.gca(projection=Axes3D.name) ax.voxels(x, y, z, sphere, facecolors=colors, edgecolors=np.clip(2*colors - 0.5, 0, 1), # brighter diff --git a/examples/mplot3d/wire3d_animation_sgskip.py b/examples/mplot3d/wire3d_animation_sgskip.py index 4e727817264c..144cb4dffd36 100644 --- a/examples/mplot3d/wire3d_animation_sgskip.py +++ b/examples/mplot3d/wire3d_animation_sgskip.py @@ -10,8 +10,7 @@ """ -# This import registers the 3D projection, but is otherwise unused. -from mpl_toolkits.mplot3d import Axes3D # noqa: F401 unused import +from mpl_toolkits.mplot3d import Axes3D import matplotlib.pyplot as plt import numpy as np @@ -27,7 +26,7 @@ def generate(X, Y, phi): fig = plt.figure() -ax = fig.add_subplot(111, projection='3d') +ax = fig.add_subplot(111, projection=Axes3D.name) # Make the X, Y meshgrid. xs = np.linspace(-1, 1, 50) diff --git a/examples/pyplots/whats_new_1_subplot3d.py b/examples/pyplots/whats_new_1_subplot3d.py index 96886b0e1f8c..afaa44632438 100644 --- a/examples/pyplots/whats_new_1_subplot3d.py +++ b/examples/pyplots/whats_new_1_subplot3d.py @@ -5,8 +5,7 @@ Create two three-dimensional plots in the same figure. """ -# This import registers the 3D projection, but is otherwise unused. -from mpl_toolkits.mplot3d import Axes3D # noqa: F401 unused import +from mpl_toolkits.mplot3d import Axes3D from matplotlib import cm #from matplotlib.ticker import LinearLocator, FixedLocator, FormatStrFormatter @@ -15,7 +14,7 @@ fig = plt.figure() -ax = fig.add_subplot(1, 2, 1, projection='3d') +ax = fig.add_subplot(1, 2, 1, projection=Axes3D.name) X = np.arange(-5, 5, 0.25) Y = np.arange(-5, 5, 0.25) X, Y = np.meshgrid(X, Y) @@ -31,7 +30,7 @@ fig.colorbar(surf, shrink=0.5, aspect=5) from mpl_toolkits.mplot3d.axes3d import get_test_data -ax = fig.add_subplot(1, 2, 2, projection='3d') +ax = fig.add_subplot(1, 2, 2, projection=Axes3D.name) X, Y, Z = get_test_data(0.05) ax.plot_wireframe(X, Y, Z, rstride=10, cstride=10)