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

Skip to content

Commit 2c265ed

Browse files
authored
Merge pull request #18419 from anntzer/ungcakw
Avoid demo'ing passing kwargs to gca().
2 parents 80eabbc + 73d51ad commit 2c265ed

22 files changed

+52
-78
lines changed

examples/mplot3d/2dcollections3d.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,7 @@
1010
import numpy as np
1111
import matplotlib.pyplot as plt
1212

13-
fig = plt.figure()
14-
ax = fig.gca(projection='3d')
13+
ax = plt.figure().add_subplot(projection='3d')
1514

1615
# Plot a sin curve using the x and y axes.
1716
x = np.linspace(0, 1, 100)

examples/mplot3d/contour3d.py

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,13 +11,10 @@
1111
import matplotlib.pyplot as plt
1212
from matplotlib import cm
1313

14-
fig = plt.figure()
15-
ax = fig.gca(projection='3d')
14+
ax = plt.figure().add_subplot(projection='3d')
1615
X, Y, Z = axes3d.get_test_data(0.05)
1716

18-
# Plot contour curves
19-
cset = ax.contour(X, Y, Z, cmap=cm.coolwarm)
20-
17+
cset = ax.contour(X, Y, Z, cmap=cm.coolwarm) # Plot contour curves
2118
ax.clabel(cset, fontsize=9, inline=True)
2219

2320
plt.show()

examples/mplot3d/contour3d_2.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,7 @@
1111
import matplotlib.pyplot as plt
1212
from matplotlib import cm
1313

14-
fig = plt.figure()
15-
ax = fig.gca(projection='3d')
14+
ax = plt.figure().add_subplot(projection='3d')
1615
X, Y, Z = axes3d.get_test_data(0.05)
1716

1817
cset = ax.contour(X, Y, Z, extend3d=True, cmap=cm.coolwarm)

examples/mplot3d/contour3d_3.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,7 @@
1313
import matplotlib.pyplot as plt
1414
from matplotlib import cm
1515

16-
fig = plt.figure()
17-
ax = fig.gca(projection='3d')
16+
ax = plt.figure().add_subplot(projection='3d')
1817
X, Y, Z = axes3d.get_test_data(0.05)
1918

2019
# Plot the 3D surface

examples/mplot3d/contourf3d.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,7 @@
1414
import matplotlib.pyplot as plt
1515
from matplotlib import cm
1616

17-
fig = plt.figure()
18-
ax = fig.gca(projection='3d')
17+
ax = plt.figure().add_subplot(projection='3d')
1918
X, Y, Z = axes3d.get_test_data(0.05)
2019

2120
cset = ax.contourf(X, Y, Z, cmap=cm.coolwarm)

examples/mplot3d/contourf3d_2.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,7 @@
1313
import matplotlib.pyplot as plt
1414
from matplotlib import cm
1515

16-
fig = plt.figure()
17-
ax = fig.gca(projection='3d')
16+
ax = plt.figure().add_subplot(projection='3d')
1817
X, Y, Z = axes3d.get_test_data(0.05)
1918

2019
# Plot the 3D surface

examples/mplot3d/errorbar3d.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,7 @@
99
import matplotlib.pyplot as plt
1010
import numpy as np
1111

12-
fig = plt.figure()
13-
ax = fig.gca(projection='3d')
12+
ax = plt.figure().add_subplot(projection='3d')
1413

1514
# setting up a parametric curve
1615
t = np.arange(0, 2*np.pi+.1, 0.01)

examples/mplot3d/lines3d.py

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,7 @@
1010
import matplotlib.pyplot as plt
1111

1212

13-
plt.rcParams['legend.fontsize'] = 10
14-
15-
fig = plt.figure()
16-
ax = fig.gca(projection='3d')
13+
ax = plt.figure().add_subplot(projection='3d')
1714

1815
# Prepare arrays x, y, z
1916
theta = np.linspace(-4 * np.pi, 4 * np.pi, 100)

examples/mplot3d/lorenz_attractor.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,8 +54,7 @@ def lorenz(x, y, z, s=10, r=28, b=2.667):
5454

5555

5656
# Plot
57-
fig = plt.figure()
58-
ax = fig.gca(projection='3d')
57+
ax = plt.figure().add_subplot(projection='3d')
5958

6059
ax.plot(xs, ys, zs, lw=0.5)
6160
ax.set_xlabel("X Axis")

examples/mplot3d/offset.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,7 @@
1717
import numpy as np
1818

1919

20-
fig = plt.figure()
21-
ax = fig.gca(projection='3d')
20+
ax = plt.figure().add_subplot(projection='3d')
2221

2322
X, Y = np.mgrid[0:6*np.pi:0.25, 0:4*np.pi:0.25]
2423
Z = np.sqrt(np.abs(np.cos(X) + np.cos(Y)))

examples/mplot3d/polys3d.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,7 @@ def polygon_under_graph(xlist, ylist):
2424
return [(xlist[0], 0.), *zip(xlist, ylist), (xlist[-1], 0.)]
2525

2626

27-
fig = plt.figure()
28-
ax = fig.gca(projection='3d')
27+
ax = plt.figure().add_subplot(projection='3d')
2928

3029
# Make verts a list such that verts[i] is a list of (x, y) pairs defining
3130
# polygon i.

examples/mplot3d/quiver3d.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,7 @@
99
import matplotlib.pyplot as plt
1010
import numpy as np
1111

12-
fig = plt.figure()
13-
ax = fig.gca(projection='3d')
12+
ax = plt.figure().add_subplot(projection='3d')
1413

1514
# Make the grid
1615
x, y, z = np.meshgrid(np.arange(-0.8, 1, 0.2),

examples/mplot3d/surface3d_3.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,7 @@
1111
import numpy as np
1212

1313

14-
fig = plt.figure()
15-
ax = fig.gca(projection='3d')
14+
ax = plt.figure().add_subplot(projection='3d')
1615

1716
# Make data.
1817
X = np.arange(-5, 5, 0.25)

examples/mplot3d/text3d.py

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -7,20 +7,17 @@
77
88
Functionality shown:
99
10-
- Using the text function with three types of 'zdir' values: None, an axis
11-
name (ex. 'x'), or a direction tuple (ex. (1, 1, 0)).
12-
- Using the text function with the color keyword.
13-
14-
- Using the text2D function to place text on a fixed position on the ax
15-
object.
16-
10+
- Using the text function with three types of 'zdir' values: None, an axis
11+
name (ex. 'x'), or a direction tuple (ex. (1, 1, 0)).
12+
- Using the text function with the color keyword.
13+
- Using the text2D function to place text on a fixed position on the ax
14+
object.
1715
"""
1816

1917
import matplotlib.pyplot as plt
2018

2119

22-
fig = plt.figure()
23-
ax = fig.gca(projection='3d')
20+
ax = plt.figure().add_subplot(projection='3d')
2421

2522
# Demo 1: zdir
2623
zdirs = (None, 'x', 'y', 'z', (1, 1, 0), (1, 1, 1))

examples/mplot3d/tricontour3d.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,7 @@
3535
y[triang.triangles].mean(axis=1))
3636
< min_radius)
3737

38-
fig = plt.figure()
39-
ax = fig.gca(projection='3d')
38+
ax = plt.figure().add_subplot(projection='3d')
4039
ax.tricontour(triang, z, cmap=plt.cm.CMRmap)
4140

4241
# Customize the view angle so it's easier to understand the plot.

examples/mplot3d/tricontourf3d.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,8 +36,7 @@
3636
y[triang.triangles].mean(axis=1))
3737
< min_radius)
3838

39-
fig = plt.figure()
40-
ax = fig.gca(projection='3d')
39+
ax = plt.figure().add_subplot(projection='3d')
4140
ax.tricontourf(triang, z, cmap=plt.cm.CMRmap)
4241

4342
# Customize the view angle so it's easier to understand the plot.

examples/mplot3d/trisurf3d.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,7 @@
2626
# Compute z to make the pringle surface.
2727
z = np.sin(-x*y)
2828

29-
fig = plt.figure()
30-
ax = fig.gca(projection='3d')
29+
ax = plt.figure().add_subplot(projection='3d')
3130

3231
ax.plot_trisurf(x, y, z, linewidth=0.2, antialiased=True)
3332

examples/mplot3d/voxels.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,7 @@
2929
colors[cube2] = 'green'
3030

3131
# and plot everything
32-
fig = plt.figure()
33-
ax = fig.gca(projection='3d')
32+
ax = plt.figure().add_subplot(projection='3d')
3433
ax.voxels(voxels, facecolors=colors, edgecolor='k')
3534

3635
plt.show()

examples/mplot3d/voxels_numpy_logo.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
66
Demonstrates using `.Axes3D.voxels` with uneven coordinates.
77
"""
8+
89
import matplotlib.pyplot as plt
910
import numpy as np
1011

@@ -39,8 +40,7 @@ def explode(data):
3940
y[:, 1::2, :] += 0.95
4041
z[:, :, 1::2] += 0.95
4142

42-
fig = plt.figure()
43-
ax = fig.gca(projection='3d')
43+
ax = plt.figure().add_subplot(projection='3d')
4444
ax.voxels(x, y, z, filled_2, facecolors=fcolors_2, edgecolors=ecolors_2)
4545

4646
plt.show()

examples/mplot3d/voxels_rgb.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,7 @@ def midpoints(x):
3333
colors[..., 2] = bc
3434

3535
# and plot everything
36-
fig = plt.figure()
37-
ax = fig.gca(projection='3d')
36+
ax = plt.figure().add_subplot(projection='3d')
3837
ax.voxels(r, g, b, sphere,
3938
facecolors=colors,
4039
edgecolors=np.clip(2*colors - 0.5, 0, 1), # brighter

examples/mplot3d/voxels_torus.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,8 +36,7 @@ def midpoints(x):
3636
colors = matplotlib.colors.hsv_to_rgb(hsv)
3737

3838
# and plot everything
39-
fig = plt.figure()
40-
ax = fig.gca(projection='3d')
39+
ax = plt.figure().add_subplot(projection='3d')
4140
ax.voxels(x, y, z, sphere,
4241
facecolors=colors,
4342
edgecolors=np.clip(2*colors - 0.5, 0, 1), # brighter

0 commit comments

Comments
 (0)