Skip to content

Register 3d projection by default. #13520

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Feb 27, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions doc/api/next_api_changes/2019-02-26-AL.rst
Original file line number Diff line number Diff line change
@@ -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")``.
1 change: 0 additions & 1 deletion doc/users/next_whats_new/2019-01-06-shaded-voxels.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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))
Expand Down
2 changes: 0 additions & 2 deletions examples/frontpage/3D.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
3 changes: 0 additions & 3 deletions examples/mplot3d/2dcollections3d.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
2 changes: 0 additions & 2 deletions examples/mplot3d/3d_bars.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
3 changes: 0 additions & 3 deletions examples/mplot3d/bars3d.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
3 changes: 0 additions & 3 deletions examples/mplot3d/custom_shaded_3d_surface.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
3 changes: 0 additions & 3 deletions examples/mplot3d/hist3d.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
3 changes: 0 additions & 3 deletions examples/mplot3d/lines3d.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
2 changes: 0 additions & 2 deletions examples/mplot3d/lorenz_attractor.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down
2 changes: 0 additions & 2 deletions examples/mplot3d/mixed_subplots.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
3 changes: 0 additions & 3 deletions examples/mplot3d/offset.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
2 changes: 0 additions & 2 deletions examples/mplot3d/pathpatch3d.py
Original file line number Diff line number Diff line change
Expand Up @@ -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


Expand Down
3 changes: 0 additions & 3 deletions examples/mplot3d/polys3d.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
3 changes: 0 additions & 3 deletions examples/mplot3d/quiver3d.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
3 changes: 0 additions & 3 deletions examples/mplot3d/scatter3d.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
2 changes: 0 additions & 2 deletions examples/mplot3d/subplot3d.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
3 changes: 0 additions & 3 deletions examples/mplot3d/surface3d.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
3 changes: 0 additions & 3 deletions examples/mplot3d/surface3d_2.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
3 changes: 0 additions & 3 deletions examples/mplot3d/surface3d_3.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
3 changes: 0 additions & 3 deletions examples/mplot3d/surface3d_radial.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
3 changes: 0 additions & 3 deletions examples/mplot3d/text3d.py
Original file line number Diff line number Diff line change
Expand Up @@ -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


Expand Down
3 changes: 0 additions & 3 deletions examples/mplot3d/tricontour3d.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
3 changes: 0 additions & 3 deletions examples/mplot3d/tricontourf3d.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
3 changes: 0 additions & 3 deletions examples/mplot3d/trisurf3d.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
3 changes: 0 additions & 3 deletions examples/mplot3d/trisurf3d_2.py
Original file line number Diff line number Diff line change
Expand Up @@ -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))

Expand Down
3 changes: 0 additions & 3 deletions examples/mplot3d/voxels.py
Original file line number Diff line number Diff line change
Expand Up @@ -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))
Expand Down
3 changes: 0 additions & 3 deletions examples/mplot3d/voxels_numpy_logo.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
3 changes: 0 additions & 3 deletions examples/mplot3d/voxels_rgb.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 = ()
Expand Down
3 changes: 0 additions & 3 deletions examples/mplot3d/voxels_torus.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 = ()
Expand Down
4 changes: 0 additions & 4 deletions examples/mplot3d/wire3d_animation_sgskip.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 0 additions & 2 deletions examples/pyplots/whats_new_1_subplot3d.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
5 changes: 4 additions & 1 deletion lib/matplotlib/projections/__init__.py
Original file line number Diff line number Diff line change
@@ -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:
Expand Down Expand Up @@ -38,7 +39,9 @@ def get_projection_names(self):
AitoffAxes,
HammerAxes,
LambertAxes,
MollweideAxes)
MollweideAxes,
Axes3D,
)


def register_projection(cls):
Expand Down
8 changes: 0 additions & 8 deletions lib/mpl_toolkits/mplot3d/axes3d.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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)