Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 3c87da1

Browse files
committed
Register 3d projection by default.
Now that we always install mpl_toolkits, we may as well always register mplot3d and save an "apparently unused" import for the users.
1 parent 867c3dd commit 3c87da1

33 files changed

+9
-85
lines changed
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
mplot3d is always registered by default
2+
```````````````````````````````````````
3+
4+
It is not necessary to import mplot3d anymore to create 3d axes with
5+
``fig.add_subplot(111, projection="3d")``.

doc/users/next_whats_new/2019-01-06-shaded-voxels.rst

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@ The plot below shows how this affects the output.
1212

1313
import matplotlib.pyplot as plt
1414
import numpy as np
15-
from mpl_toolkits.mplot3d import Axes3D # noqa: F401 unused import
1615

1716
# prepare some coordinates
1817
x, y, z = np.indices((8, 8, 8))

examples/frontpage/3D.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,6 @@
66
This example reproduces the frontpage 3D example.
77
88
"""
9-
# This import registers the 3D projection, but is otherwise unused.
10-
from mpl_toolkits.mplot3d import Axes3D # noqa: F401 unused import
119

1210
from matplotlib import cbook
1311
from matplotlib import cm

examples/mplot3d/2dcollections3d.py

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,6 @@
77
selective axes of a 3D plot.
88
"""
99

10-
# This import registers the 3D projection, but is otherwise unused.
11-
from mpl_toolkits.mplot3d import Axes3D # noqa: F401 unused import
12-
1310
import numpy as np
1411
import matplotlib.pyplot as plt
1512

examples/mplot3d/3d_bars.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,6 @@
1010

1111
import numpy as np
1212
import matplotlib.pyplot as plt
13-
# This import registers the 3D projection, but is otherwise unused.
14-
from mpl_toolkits.mplot3d import Axes3D # noqa: F401 unused import
1513

1614

1715
# setup the figure and axes

examples/mplot3d/bars3d.py

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,6 @@
77
planes y=0, y=1, etc.
88
"""
99

10-
# This import registers the 3D projection, but is otherwise unused.
11-
from mpl_toolkits.mplot3d import Axes3D # noqa: F401 unused import
12-
1310
import matplotlib.pyplot as plt
1411
import numpy as np
1512

examples/mplot3d/custom_shaded_3d_surface.py

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,6 @@
66
Demonstrates using custom hillshading in a 3D surface plot.
77
"""
88

9-
# This import registers the 3D projection, but is otherwise unused.
10-
from mpl_toolkits.mplot3d import Axes3D # noqa: F401 unused import
11-
129
from matplotlib import cbook
1310
from matplotlib import cm
1411
from matplotlib.colors import LightSource

examples/mplot3d/hist3d.py

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,6 @@
66
Demo of a histogram for 2 dimensional data as a bar graph in 3D.
77
"""
88

9-
# This import registers the 3D projection, but is otherwise unused.
10-
from mpl_toolkits.mplot3d import Axes3D # noqa: F401 unused import
11-
129
import matplotlib.pyplot as plt
1310
import numpy as np
1411

examples/mplot3d/lines3d.py

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,6 @@
66
This example demonstrates plotting a parametric curve in 3D.
77
'''
88

9-
# This import registers the 3D projection, but is otherwise unused.
10-
from mpl_toolkits.mplot3d import Axes3D # noqa: F401 unused import
11-
129
import numpy as np
1310
import matplotlib.pyplot as plt
1411

examples/mplot3d/lorenz_attractor.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,6 @@
1515

1616
import numpy as np
1717
import matplotlib.pyplot as plt
18-
# This import registers the 3D projection, but is otherwise unused.
19-
from mpl_toolkits.mplot3d import Axes3D # noqa: F401 unused import
2018

2119

2220
def lorenz(x, y, z, s=10, r=28, b=2.667):

examples/mplot3d/mixed_subplots.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,6 @@
55
66
This example shows a how to plot a 2D and 3D plot on the same figure.
77
"""
8-
# This import registers the 3D projection, but is otherwise unused.
9-
from mpl_toolkits.mplot3d import Axes3D # noqa: F401 unused import
108

119
import matplotlib.pyplot as plt
1210
import numpy as np

examples/mplot3d/offset.py

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,6 @@
1313
automatically trigger it.
1414
'''
1515

16-
# This import registers the 3D projection, but is otherwise unused.
17-
from mpl_toolkits.mplot3d import Axes3D # noqa: F401 unused import
18-
1916
import matplotlib.pyplot as plt
2017
import numpy as np
2118

examples/mplot3d/pathpatch3d.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,6 @@
1111
from matplotlib.patches import Circle, PathPatch
1212
from matplotlib.text import TextPath
1313
from matplotlib.transforms import Affine2D
14-
# This import registers the 3D projection, but is otherwise unused.
15-
from mpl_toolkits.mplot3d import Axes3D # noqa: F401 unused import
1614
import mpl_toolkits.mplot3d.art3d as art3d
1715

1816

examples/mplot3d/polys3d.py

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,6 @@
88
of 'jagged stained glass' effect.
99
"""
1010

11-
# This import registers the 3D projection, but is otherwise unused.
12-
from mpl_toolkits.mplot3d import Axes3D # noqa: F401 unused import
13-
1411
from matplotlib.collections import PolyCollection
1512
import matplotlib.pyplot as plt
1613
from matplotlib import colors as mcolors

examples/mplot3d/quiver3d.py

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,6 @@
66
Demonstrates plotting directional arrows at points on a 3d meshgrid.
77
'''
88

9-
# This import registers the 3D projection, but is otherwise unused.
10-
from mpl_toolkits.mplot3d import Axes3D # noqa: F401 unused import
11-
129
import matplotlib.pyplot as plt
1310
import numpy as np
1411

examples/mplot3d/scatter3d.py

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,6 @@
66
Demonstration of a basic scatterplot in 3D.
77
'''
88

9-
# This import registers the 3D projection, but is otherwise unused.
10-
from mpl_toolkits.mplot3d import Axes3D # noqa: F401 unused import
11-
129
import matplotlib.pyplot as plt
1310
import numpy as np
1411

examples/mplot3d/subplot3d.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,6 @@
1111
import numpy as np
1212

1313
from mpl_toolkits.mplot3d.axes3d import get_test_data
14-
# This import registers the 3D projection, but is otherwise unused.
15-
from mpl_toolkits.mplot3d import Axes3D # noqa: F401 unused import
1614

1715

1816
# set up a figure twice as wide as it is tall

examples/mplot3d/surface3d.py

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,6 @@
1010
z axis tick labels.
1111
'''
1212

13-
# This import registers the 3D projection, but is otherwise unused.
14-
from mpl_toolkits.mplot3d import Axes3D # noqa: F401 unused import
15-
1613
import matplotlib.pyplot as plt
1714
from matplotlib import cm
1815
from matplotlib.ticker import LinearLocator, FormatStrFormatter

examples/mplot3d/surface3d_2.py

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,6 @@
66
Demonstrates a very basic plot of a 3D surface using a solid color.
77
'''
88

9-
# This import registers the 3D projection, but is otherwise unused.
10-
from mpl_toolkits.mplot3d import Axes3D # noqa: F401 unused import
11-
129
import matplotlib.pyplot as plt
1310
import numpy as np
1411

examples/mplot3d/surface3d_3.py

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,6 @@
66
Demonstrates plotting a 3D surface colored in a checkerboard pattern.
77
'''
88

9-
# This import registers the 3D projection, but is otherwise unused.
10-
from mpl_toolkits.mplot3d import Axes3D # noqa: F401 unused import
11-
129
import matplotlib.pyplot as plt
1310
from matplotlib.ticker import LinearLocator
1411
import numpy as np

examples/mplot3d/surface3d_radial.py

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,6 @@
1010
Example contributed by Armin Moser.
1111
'''
1212

13-
# This import registers the 3D projection, but is otherwise unused.
14-
from mpl_toolkits.mplot3d import Axes3D # noqa: F401 unused import
15-
1613
import matplotlib.pyplot as plt
1714
import numpy as np
1815

examples/mplot3d/text3d.py

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,6 @@
1616
1717
'''
1818

19-
# This import registers the 3D projection, but is otherwise unused.
20-
from mpl_toolkits.mplot3d import Axes3D # noqa: F401 unused import
21-
2219
import matplotlib.pyplot as plt
2320

2421

examples/mplot3d/tricontour3d.py

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,6 @@
99
tricontourf3d_demo shows the filled version of this example.
1010
"""
1111

12-
# This import registers the 3D projection, but is otherwise unused.
13-
from mpl_toolkits.mplot3d import Axes3D # noqa: F401 unused import
14-
1512
import matplotlib.pyplot as plt
1613
import matplotlib.tri as tri
1714
import numpy as np

examples/mplot3d/tricontourf3d.py

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,6 @@
99
tricontour3d_demo shows the unfilled version of this example.
1010
"""
1111

12-
# This import registers the 3D projection, but is otherwise unused.
13-
from mpl_toolkits.mplot3d import Axes3D # noqa: F401 unused import
14-
1512
import matplotlib.pyplot as plt
1613
import matplotlib.tri as tri
1714
import numpy as np

examples/mplot3d/trisurf3d.py

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,6 @@
66
Plot a 3D surface with a triangular mesh.
77
'''
88

9-
# This import registers the 3D projection, but is otherwise unused.
10-
from mpl_toolkits.mplot3d import Axes3D # noqa: F401 unused import
11-
129
import matplotlib.pyplot as plt
1310
import numpy as np
1411

examples/mplot3d/trisurf3d_2.py

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,6 @@
1414
import matplotlib.pyplot as plt
1515
import matplotlib.tri as mtri
1616

17-
# This import registers the 3D projection, but is otherwise unused.
18-
from mpl_toolkits.mplot3d import Axes3D # noqa: F401 unused import
19-
2017

2118
fig = plt.figure(figsize=plt.figaspect(0.5))
2219

examples/mplot3d/voxels.py

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,6 @@
99
import matplotlib.pyplot as plt
1010
import numpy as np
1111

12-
# This import registers the 3D projection, but is otherwise unused.
13-
from mpl_toolkits.mplot3d import Axes3D # noqa: F401 unused import
14-
1512

1613
# prepare some coordinates
1714
x, y, z = np.indices((8, 8, 8))

examples/mplot3d/voxels_numpy_logo.py

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,6 @@
88
import matplotlib.pyplot as plt
99
import numpy as np
1010

11-
# This import registers the 3D projection, but is otherwise unused.
12-
from mpl_toolkits.mplot3d import Axes3D # noqa: F401 unused import
13-
1411

1512
def explode(data):
1613
size = np.array(data.shape)*2

examples/mplot3d/voxels_rgb.py

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,6 @@
99
import matplotlib.pyplot as plt
1010
import numpy as np
1111

12-
# This import registers the 3D projection, but is otherwise unused.
13-
from mpl_toolkits.mplot3d import Axes3D # noqa: F401 unused import
14-
1512

1613
def midpoints(x):
1714
sl = ()

examples/mplot3d/voxels_torus.py

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,6 @@
1010
import matplotlib.colors
1111
import numpy as np
1212

13-
# This import registers the 3D projection, but is otherwise unused.
14-
from mpl_toolkits.mplot3d import Axes3D # noqa: F401 unused import
15-
1613

1714
def midpoints(x):
1815
sl = ()

examples/mplot3d/wire3d_animation_sgskip.py

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,6 @@
99
intentionally takes a long time to run)
1010
"""
1111

12-
13-
# This import registers the 3D projection, but is otherwise unused.
14-
from mpl_toolkits.mplot3d import Axes3D # noqa: F401 unused import
15-
1612
import matplotlib.pyplot as plt
1713
import numpy as np
1814
import time

examples/pyplots/whats_new_1_subplot3d.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,6 @@
55
66
Create two three-dimensional plots in the same figure.
77
"""
8-
# This import registers the 3D projection, but is otherwise unused.
9-
from mpl_toolkits.mplot3d import Axes3D # noqa: F401 unused import
108

119
from matplotlib import cm
1210
#from matplotlib.ticker import LinearLocator, FixedLocator, FormatStrFormatter

lib/matplotlib/projections/__init__.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,3 +70,7 @@ def get_projection_names():
7070
Get a list of acceptable projection names.
7171
"""
7272
return projection_registry.get_projection_names()
73+
74+
75+
# Register Axes3D.
76+
from mpl_toolkits import mplot3d as _ # noqa: F402 non-top-import.

0 commit comments

Comments
 (0)