diff --git a/doc/api/next_api_changes/2019-02-26-AL.rst b/doc/api/next_api_changes/2019-02-26-AL.rst new file mode 100644 index 000000000000..9d8f8653a97e --- /dev/null +++ b/doc/api/next_api_changes/2019-02-26-AL.rst @@ -0,0 +1,5 @@ +mplot3d is always registered by default +``````````````````````````````````````` + +It is not necessary to import mplot3d anymore to create 3d axes with +``fig.add_subplot(111, projection="3d")``. diff --git a/doc/users/next_whats_new/2019-01-06-shaded-voxels.rst b/doc/users/next_whats_new/2019-01-06-shaded-voxels.rst index 6a12b673007d..ec6db4ae68bf 100644 --- a/doc/users/next_whats_new/2019-01-06-shaded-voxels.rst +++ b/doc/users/next_whats_new/2019-01-06-shaded-voxels.rst @@ -12,7 +12,6 @@ The plot below shows how this affects the output. import matplotlib.pyplot as plt import numpy as np - from mpl_toolkits.mplot3d import Axes3D # noqa: F401 unused import # prepare some coordinates x, y, z = np.indices((8, 8, 8)) diff --git a/examples/frontpage/3D.py b/examples/frontpage/3D.py index ee93026ed06e..986e95ad71ca 100644 --- a/examples/frontpage/3D.py +++ b/examples/frontpage/3D.py @@ -6,8 +6,6 @@ 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 matplotlib import cbook from matplotlib import cm diff --git a/examples/mplot3d/2dcollections3d.py b/examples/mplot3d/2dcollections3d.py index 589e1083f7f5..f07275e0468d 100644 --- a/examples/mplot3d/2dcollections3d.py +++ b/examples/mplot3d/2dcollections3d.py @@ -7,9 +7,6 @@ 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 - import numpy as np import matplotlib.pyplot as plt diff --git a/examples/mplot3d/3d_bars.py b/examples/mplot3d/3d_bars.py index 483dbcc4fb71..e06c1a1cf04d 100644 --- a/examples/mplot3d/3d_bars.py +++ b/examples/mplot3d/3d_bars.py @@ -10,8 +10,6 @@ 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 # setup the figure and axes diff --git a/examples/mplot3d/bars3d.py b/examples/mplot3d/bars3d.py index e30175ffac41..7ce1740db49c 100644 --- a/examples/mplot3d/bars3d.py +++ b/examples/mplot3d/bars3d.py @@ -7,9 +7,6 @@ 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 - import matplotlib.pyplot as plt import numpy as np diff --git a/examples/mplot3d/custom_shaded_3d_surface.py b/examples/mplot3d/custom_shaded_3d_surface.py index 366658856470..514a293a7ca1 100644 --- a/examples/mplot3d/custom_shaded_3d_surface.py +++ b/examples/mplot3d/custom_shaded_3d_surface.py @@ -6,9 +6,6 @@ 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 matplotlib import cbook from matplotlib import cm from matplotlib.colors import LightSource diff --git a/examples/mplot3d/hist3d.py b/examples/mplot3d/hist3d.py index c7c71d12f532..0ec003d61fdd 100644 --- a/examples/mplot3d/hist3d.py +++ b/examples/mplot3d/hist3d.py @@ -6,9 +6,6 @@ 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 - import matplotlib.pyplot as plt import numpy as np diff --git a/examples/mplot3d/lines3d.py b/examples/mplot3d/lines3d.py index e0e45b1c051c..325d41a50db3 100644 --- a/examples/mplot3d/lines3d.py +++ b/examples/mplot3d/lines3d.py @@ -6,9 +6,6 @@ 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 - import numpy as np import matplotlib.pyplot as plt diff --git a/examples/mplot3d/lorenz_attractor.py b/examples/mplot3d/lorenz_attractor.py index ec4ed01f7c61..26d29e0ee801 100644 --- a/examples/mplot3d/lorenz_attractor.py +++ b/examples/mplot3d/lorenz_attractor.py @@ -15,8 +15,6 @@ 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 def lorenz(x, y, z, s=10, r=28, b=2.667): diff --git a/examples/mplot3d/mixed_subplots.py b/examples/mplot3d/mixed_subplots.py index a325171e3c8d..df981ceee4ea 100644 --- a/examples/mplot3d/mixed_subplots.py +++ b/examples/mplot3d/mixed_subplots.py @@ -5,8 +5,6 @@ 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 import matplotlib.pyplot as plt import numpy as np diff --git a/examples/mplot3d/offset.py b/examples/mplot3d/offset.py index 04c56ed2066e..f4f2a4893e44 100644 --- a/examples/mplot3d/offset.py +++ b/examples/mplot3d/offset.py @@ -13,9 +13,6 @@ automatically trigger it. ''' -# This import registers the 3D projection, but is otherwise unused. -from mpl_toolkits.mplot3d import Axes3D # noqa: F401 unused import - import matplotlib.pyplot as plt import numpy as np diff --git a/examples/mplot3d/pathpatch3d.py b/examples/mplot3d/pathpatch3d.py index 962e54d8dce6..d57909acf978 100644 --- a/examples/mplot3d/pathpatch3d.py +++ b/examples/mplot3d/pathpatch3d.py @@ -11,8 +11,6 @@ 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 import mpl_toolkits.mplot3d.art3d as art3d diff --git a/examples/mplot3d/polys3d.py b/examples/mplot3d/polys3d.py index 58724a2dc462..3759175d56bf 100644 --- a/examples/mplot3d/polys3d.py +++ b/examples/mplot3d/polys3d.py @@ -8,9 +8,6 @@ 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 matplotlib.collections import PolyCollection import matplotlib.pyplot as plt from matplotlib import colors as mcolors diff --git a/examples/mplot3d/quiver3d.py b/examples/mplot3d/quiver3d.py index 6921b4a1d26c..1d0a84aa54da 100644 --- a/examples/mplot3d/quiver3d.py +++ b/examples/mplot3d/quiver3d.py @@ -6,9 +6,6 @@ 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 - import matplotlib.pyplot as plt import numpy as np diff --git a/examples/mplot3d/scatter3d.py b/examples/mplot3d/scatter3d.py index 46648d3a806e..ffac80086d8a 100644 --- a/examples/mplot3d/scatter3d.py +++ b/examples/mplot3d/scatter3d.py @@ -6,9 +6,6 @@ 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 - import matplotlib.pyplot as plt import numpy as np diff --git a/examples/mplot3d/subplot3d.py b/examples/mplot3d/subplot3d.py index e9c1c3f2d712..a9e054721ce2 100644 --- a/examples/mplot3d/subplot3d.py +++ b/examples/mplot3d/subplot3d.py @@ -11,8 +11,6 @@ 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 # set up a figure twice as wide as it is tall diff --git a/examples/mplot3d/surface3d.py b/examples/mplot3d/surface3d.py index eac122b6aa13..a614c8bb587b 100644 --- a/examples/mplot3d/surface3d.py +++ b/examples/mplot3d/surface3d.py @@ -10,9 +10,6 @@ z axis tick labels. ''' -# This import registers the 3D projection, but is otherwise unused. -from mpl_toolkits.mplot3d import Axes3D # noqa: F401 unused import - import matplotlib.pyplot as plt from matplotlib import cm from matplotlib.ticker import LinearLocator, FormatStrFormatter diff --git a/examples/mplot3d/surface3d_2.py b/examples/mplot3d/surface3d_2.py index 226e8bf35438..7aef8c6b049c 100644 --- a/examples/mplot3d/surface3d_2.py +++ b/examples/mplot3d/surface3d_2.py @@ -6,9 +6,6 @@ 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 - import matplotlib.pyplot as plt import numpy as np diff --git a/examples/mplot3d/surface3d_3.py b/examples/mplot3d/surface3d_3.py index d75dc6680152..b2f993987051 100644 --- a/examples/mplot3d/surface3d_3.py +++ b/examples/mplot3d/surface3d_3.py @@ -6,9 +6,6 @@ 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 - import matplotlib.pyplot as plt from matplotlib.ticker import LinearLocator import numpy as np diff --git a/examples/mplot3d/surface3d_radial.py b/examples/mplot3d/surface3d_radial.py index 521f6195330d..1f10e810e3be 100644 --- a/examples/mplot3d/surface3d_radial.py +++ b/examples/mplot3d/surface3d_radial.py @@ -10,9 +10,6 @@ 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 - import matplotlib.pyplot as plt import numpy as np diff --git a/examples/mplot3d/text3d.py b/examples/mplot3d/text3d.py index ed4934faf5a1..74cfd791fce6 100644 --- a/examples/mplot3d/text3d.py +++ b/examples/mplot3d/text3d.py @@ -16,9 +16,6 @@ ''' -# This import registers the 3D projection, but is otherwise unused. -from mpl_toolkits.mplot3d import Axes3D # noqa: F401 unused import - import matplotlib.pyplot as plt diff --git a/examples/mplot3d/tricontour3d.py b/examples/mplot3d/tricontour3d.py index feb187cbaa16..96350db544a6 100644 --- a/examples/mplot3d/tricontour3d.py +++ b/examples/mplot3d/tricontour3d.py @@ -9,9 +9,6 @@ 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 - import matplotlib.pyplot as plt import matplotlib.tri as tri import numpy as np diff --git a/examples/mplot3d/tricontourf3d.py b/examples/mplot3d/tricontourf3d.py index d25b2dbd1ea5..772ff78e063f 100644 --- a/examples/mplot3d/tricontourf3d.py +++ b/examples/mplot3d/tricontourf3d.py @@ -9,9 +9,6 @@ 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 - import matplotlib.pyplot as plt import matplotlib.tri as tri import numpy as np diff --git a/examples/mplot3d/trisurf3d.py b/examples/mplot3d/trisurf3d.py index 070a3154f2cb..19cbb4d577f6 100644 --- a/examples/mplot3d/trisurf3d.py +++ b/examples/mplot3d/trisurf3d.py @@ -6,9 +6,6 @@ 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 - import matplotlib.pyplot as plt import numpy as np diff --git a/examples/mplot3d/trisurf3d_2.py b/examples/mplot3d/trisurf3d_2.py index 35994b39b2ab..88011e1148d4 100644 --- a/examples/mplot3d/trisurf3d_2.py +++ b/examples/mplot3d/trisurf3d_2.py @@ -14,9 +14,6 @@ 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 - fig = plt.figure(figsize=plt.figaspect(0.5)) diff --git a/examples/mplot3d/voxels.py b/examples/mplot3d/voxels.py index 4ba96fff6c65..ba587519e4d2 100644 --- a/examples/mplot3d/voxels.py +++ b/examples/mplot3d/voxels.py @@ -9,9 +9,6 @@ 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 - # prepare some coordinates x, y, z = np.indices((8, 8, 8)) diff --git a/examples/mplot3d/voxels_numpy_logo.py b/examples/mplot3d/voxels_numpy_logo.py index 38b00b49f4de..f93731f3447b 100644 --- a/examples/mplot3d/voxels_numpy_logo.py +++ b/examples/mplot3d/voxels_numpy_logo.py @@ -8,9 +8,6 @@ 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 - def explode(data): size = np.array(data.shape)*2 diff --git a/examples/mplot3d/voxels_rgb.py b/examples/mplot3d/voxels_rgb.py index 7b012b2a61f8..8beb25502a34 100644 --- a/examples/mplot3d/voxels_rgb.py +++ b/examples/mplot3d/voxels_rgb.py @@ -9,9 +9,6 @@ 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 - def midpoints(x): sl = () diff --git a/examples/mplot3d/voxels_torus.py b/examples/mplot3d/voxels_torus.py index 3112f82792da..cdd4fde34752 100644 --- a/examples/mplot3d/voxels_torus.py +++ b/examples/mplot3d/voxels_torus.py @@ -10,9 +10,6 @@ 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 - def midpoints(x): sl = () diff --git a/examples/mplot3d/wire3d_animation_sgskip.py b/examples/mplot3d/wire3d_animation_sgskip.py index 4e727817264c..79b4108a7299 100644 --- a/examples/mplot3d/wire3d_animation_sgskip.py +++ b/examples/mplot3d/wire3d_animation_sgskip.py @@ -9,10 +9,6 @@ intentionally takes a long time to run) """ - -# This import registers the 3D projection, but is otherwise unused. -from mpl_toolkits.mplot3d import Axes3D # noqa: F401 unused import - import matplotlib.pyplot as plt import numpy as np import time diff --git a/examples/pyplots/whats_new_1_subplot3d.py b/examples/pyplots/whats_new_1_subplot3d.py index ee18562bdead..1996e18f96f3 100644 --- a/examples/pyplots/whats_new_1_subplot3d.py +++ b/examples/pyplots/whats_new_1_subplot3d.py @@ -5,8 +5,6 @@ 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 matplotlib import cm #from matplotlib.ticker import LinearLocator, FixedLocator, FormatStrFormatter diff --git a/lib/matplotlib/projections/__init__.py b/lib/matplotlib/projections/__init__.py index 7e4a34fb8bfc..e318bbc12514 100644 --- a/lib/matplotlib/projections/__init__.py +++ b/lib/matplotlib/projections/__init__.py @@ -1,6 +1,7 @@ from .. import axes, cbook from .geo import AitoffAxes, HammerAxes, LambertAxes, MollweideAxes from .polar import PolarAxes +from mpl_toolkits.mplot3d import Axes3D class ProjectionRegistry: @@ -38,7 +39,9 @@ def get_projection_names(self): AitoffAxes, HammerAxes, LambertAxes, - MollweideAxes) + MollweideAxes, + Axes3D, +) def register_projection(cls): diff --git a/lib/mpl_toolkits/mplot3d/axes3d.py b/lib/mpl_toolkits/mplot3d/axes3d.py index e4a13f3e200e..ccf658bbc72d 100644 --- a/lib/mpl_toolkits/mplot3d/axes3d.py +++ b/lib/mpl_toolkits/mplot3d/axes3d.py @@ -21,7 +21,6 @@ import matplotlib.collections as mcoll import matplotlib.colors as mcolors import matplotlib.docstring as docstring -import matplotlib.projections as proj import matplotlib.scale as mscale import matplotlib.transforms as mtransforms from matplotlib.axes import Axes, rcParams @@ -2975,10 +2974,3 @@ def get_test_data(delta=0.05): Y = Y * 10 Z = Z * 500 return X, Y, Z - - -######################################################## -# Register Axes3D as a 'projection' object available -# for use just like any other axes -######################################################## -proj.projection_registry.register(Axes3D)