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)))

0 commit comments

Comments
 (0)