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

Skip to content

Commit 52b7555

Browse files
committed
Change subplot(111, ...) to subplot(...) as 111 is the default.
1 parent 2486ba2 commit 52b7555

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

64 files changed

+144
-147
lines changed

examples/animation/double_pendulum.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ def derivs(state, t):
7171
y2 = -L2*cos(y[:, 2]) + y1
7272

7373
fig = plt.figure(figsize=(5, 4))
74-
ax = fig.add_subplot(111, autoscale_on=False, xlim=(-2, 2), ylim=(-2, 1))
74+
ax = fig.add_subplot(autoscale_on=False, xlim=(-2, 2), ylim=(-2, 1))
7575
ax.set_aspect('equal')
7676
ax.grid()
7777

examples/animation/unchained.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
fig = plt.figure(figsize=(8, 8), facecolor='black')
2222

2323
# Add a subplot with no frame
24-
ax = plt.subplot(111, frameon=False)
24+
ax = plt.subplot(frameon=False)
2525

2626
# Generate random data
2727
data = np.random.uniform(0, 1, (64, 75))

examples/axes_grid1/simple_colorbar.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
from mpl_toolkits.axes_grid1 import make_axes_locatable
99
import numpy as np
1010

11-
ax = plt.subplot(111)
11+
ax = plt.subplot()
1212
im = ax.imshow(np.arange(100).reshape((10, 10)))
1313

1414
# create an axes on the right side of ax. The width of cax will be 5%

examples/event_handling/trifinder_event_demo.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ def on_mouse_move(event):
5252
trifinder = triang.get_trifinder()
5353

5454
# Setup plot and callbacks.
55-
plt.subplot(111, aspect='equal')
55+
plt.subplot(aspect='equal')
5656
plt.triplot(triang, 'bo-')
5757
polygon = Polygon([[0, 0], [0, 0]], facecolor='y') # dummy data for (xs, ys)
5858
update_polygon(-1)

examples/misc/agg_buffer_to_array.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,6 @@
2525

2626
# now display the array X as an Axes in a new figure
2727
fig2 = plt.figure()
28-
ax2 = fig2.add_subplot(111, frameon=False)
28+
ax2 = fig2.add_subplot(frameon=False)
2929
ax2.imshow(X)
3030
plt.show()

examples/misc/custom_projection.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -370,7 +370,7 @@ class HammerAxes(GeoAxes):
370370

371371
# The projection must specify a name. This will be used by the
372372
# user to select the projection,
373-
# i.e. ``subplot(111, projection='custom_hammer')``.
373+
# i.e. ``subplot(projection='custom_hammer')``.
374374
name = 'custom_hammer'
375375

376376
class HammerTransform(Transform):
@@ -441,7 +441,7 @@ def _get_core_transform(self, resolution):
441441
if __name__ == '__main__':
442442
import matplotlib.pyplot as plt
443443
# Now make a simple example using the custom projection.
444-
plt.subplot(111, projection="custom_hammer")
444+
plt.subplot(projection="custom_hammer")
445445
p = plt.plot([-1, 1, 1], [-1, -1, 1], "o-")
446446
plt.grid(True)
447447

examples/misc/customize_rc.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@ def set_pub():
2626
Then as you are working interactively, you just need to do::
2727
2828
>>> set_pub()
29-
>>> subplot(111)
3029
>>> plot([1, 2, 3])
3130
>>> savefig('myfig')
3231
>>> rcdefaults() # restore the defaults

examples/mplot3d/bars3d.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515

1616

1717
fig = plt.figure()
18-
ax = fig.add_subplot(111, projection='3d')
18+
ax = fig.add_subplot(projection='3d')
1919

2020
colors = ['r', 'g', 'b', 'y']
2121
yticks = [3, 2, 1, 0]

examples/mplot3d/hist3d.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414

1515

1616
fig = plt.figure()
17-
ax = fig.add_subplot(111, projection='3d')
17+
ax = fig.add_subplot(projection='3d')
1818
x, y = np.random.rand(2, 100) * 4
1919
hist, xedges, yedges = np.histogram2d(x, y, bins=4, range=[[0, 4], [0, 4]])
2020

examples/mplot3d/pathpatch3d.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ def text3d(ax, xyz, s, zdir="z", size=None, angle=0, usetex=False, **kwargs):
4141

4242

4343
fig = plt.figure()
44-
ax = fig.add_subplot(111, projection='3d')
44+
ax = fig.add_subplot(projection='3d')
4545

4646
# Draw a circle on the x=0 'wall'
4747
p = Circle((5, 5), 3)

examples/mplot3d/rotate_axes3d_sgskip.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
import matplotlib.pyplot as plt
1616

1717
fig = plt.figure()
18-
ax = fig.add_subplot(111, projection='3d')
18+
ax = fig.add_subplot(projection='3d')
1919

2020
# load some test data for demonstration and plot a wireframe
2121
X, Y, Z = axes3d.get_test_data(0.1)

examples/mplot3d/scatter3d.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ def randrange(n, vmin, vmax):
2121
return (vmax - vmin)*np.random.rand(n) + vmin
2222

2323
fig = plt.figure()
24-
ax = fig.add_subplot(111, projection='3d')
24+
ax = fig.add_subplot(projection='3d')
2525

2626
n = 100
2727

examples/mplot3d/surface3d_2.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111

1212

1313
fig = plt.figure()
14-
ax = fig.add_subplot(111, projection='3d')
14+
ax = fig.add_subplot(projection='3d')
1515

1616
# Make data
1717
u = np.linspace(0, 2 * np.pi, 100)

examples/mplot3d/surface3d_radial.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515

1616

1717
fig = plt.figure()
18-
ax = fig.add_subplot(111, projection='3d')
18+
ax = fig.add_subplot(projection='3d')
1919

2020
# Create the mesh in polar coordinates and compute corresponding Z.
2121
r = np.linspace(0, 1.25, 50)

examples/mplot3d/wire3d.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111

1212

1313
fig = plt.figure()
14-
ax = fig.add_subplot(111, projection='3d')
14+
ax = fig.add_subplot(projection='3d')
1515

1616
# Grab some test data.
1717
X, Y, Z = axes3d.get_test_data(0.05)

examples/mplot3d/wire3d_animation_sgskip.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ def generate(X, Y, phi):
2323

2424

2525
fig = plt.figure()
26-
ax = fig.add_subplot(111, projection='3d')
26+
ax = fig.add_subplot(projection='3d')
2727

2828
# Make the X, Y meshgrid.
2929
xs = np.linspace(-1, 1, 50)

examples/pie_and_polar_charts/polar_bar.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
width = np.pi / 4 * np.random.rand(N)
2020
colors = plt.cm.viridis(radii / 10.)
2121

22-
ax = plt.subplot(111, projection='polar')
22+
ax = plt.subplot(projection='polar')
2323
ax.bar(theta, radii, width=width, bottom=0.0, color=colors, alpha=0.5)
2424

2525
plt.show()

examples/pie_and_polar_charts/polar_scatter.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
colors = theta
2222

2323
fig = plt.figure()
24-
ax = fig.add_subplot(111, projection='polar')
24+
ax = fig.add_subplot(projection='polar')
2525
c = ax.scatter(theta, r, c=colors, s=area, cmap='hsv', alpha=0.75)
2626

2727
###############################################################################
@@ -33,7 +33,7 @@
3333
# rotate the plot.
3434

3535
fig = plt.figure()
36-
ax = fig.add_subplot(111, polar=True)
36+
ax = fig.add_subplot(polar=True)
3737
c = ax.scatter(theta, r, c=colors, s=area, cmap='hsv', alpha=0.75)
3838

3939
ax.set_rorigin(-2.5)
@@ -47,7 +47,7 @@
4747
# theta start and end limits, producing a sector instead of a full circle.
4848

4949
fig = plt.figure()
50-
ax = fig.add_subplot(111, polar=True)
50+
ax = fig.add_subplot(polar=True)
5151
c = ax.scatter(theta, r, c=colors, s=area, cmap='hsv', alpha=0.75)
5252

5353
ax.set_thetamin(45)

examples/pyplots/annotation_polar.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
import matplotlib.pyplot as plt
1313

1414
fig = plt.figure()
15-
ax = fig.add_subplot(111, polar=True)
15+
ax = fig.add_subplot(polar=True)
1616
r = np.arange(0, 1, 0.001)
1717
theta = 2 * 2*np.pi * r
1818
line, = ax.plot(theta, r, color='#ee8d18', lw=3)

examples/pyplots/text_commands.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
fig = plt.figure()
1212
fig.suptitle('bold figure suptitle', fontsize=14, fontweight='bold')
1313

14-
ax = fig.add_subplot(111)
14+
ax = fig.add_subplot()
1515
fig.subplots_adjust(top=0.85)
1616
ax.set_title('axes title')
1717

examples/pyplots/whats_new_98_4_legend.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
import numpy as np
1010

1111

12-
ax = plt.subplot(111)
12+
ax = plt.subplot()
1313
t1 = np.arange(0.0, 1.0, 0.01)
1414
for n in [1, 2, 3, 4]:
1515
plt.plot(t1, t1**n, label=f"n={n}")

examples/specialty_plots/skewt.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -79,8 +79,7 @@ def _adjust_location(self):
7979
# spines and axes instances as appropriate.
8080
class SkewXAxes(Axes):
8181
# The projection must specify a name. This will be used be the
82-
# user to select the projection, i.e. ``subplot(111,
83-
# projection='skewx')``.
82+
# user to select the projection, i.e. ``subplot(projection='skewx')``.
8483
name = 'skewx'
8584

8685
def _init_axis(self):
@@ -236,7 +235,7 @@ def upper_xlim(self):
236235

237236
# Create a new figure. The dimensions here give a good aspect ratio
238237
fig = plt.figure(figsize=(6.5875, 6.2125))
239-
ax = fig.add_subplot(111, projection='skewx')
238+
ax = fig.add_subplot(projection='skewx')
240239

241240
plt.grid(True)
242241

examples/subplots_axes_and_figures/geo_demo.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,28 +14,28 @@
1414
###############################################################################
1515

1616
plt.figure()
17-
plt.subplot(111, projection="aitoff")
17+
plt.subplot(projection="aitoff")
1818
plt.title("Aitoff")
1919
plt.grid(True)
2020

2121
###############################################################################
2222

2323
plt.figure()
24-
plt.subplot(111, projection="hammer")
24+
plt.subplot(projection="hammer")
2525
plt.title("Hammer")
2626
plt.grid(True)
2727

2828
###############################################################################
2929

3030
plt.figure()
31-
plt.subplot(111, projection="lambert")
31+
plt.subplot(projection="lambert")
3232
plt.title("Lambert")
3333
plt.grid(True)
3434

3535
###############################################################################
3636

3737
plt.figure()
38-
plt.subplot(111, projection="mollweide")
38+
plt.subplot(projection="mollweide")
3939
plt.title("Mollweide")
4040
plt.grid(True)
4141

examples/user_interfaces/canvasagg.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@
3030
canvas = FigureCanvasAgg(fig)
3131

3232
# Do some plotting.
33-
ax = fig.add_subplot(111)
33+
ax = fig.add_subplot()
3434
ax.plot([1, 2, 3])
3535

3636
# Option 1: Save the figure to a file; can also be a file-like object (BytesIO,

examples/user_interfaces/embedding_in_gtk3_sgskip.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
win.set_title("Embedding in GTK")
2323

2424
fig = Figure(figsize=(5, 4), dpi=100)
25-
ax = fig.add_subplot(111)
25+
ax = fig.add_subplot()
2626
t = np.arange(0.0, 3.0, 0.01)
2727
s = np.sin(2*np.pi*t)
2828
ax.plot(t, s)

examples/user_interfaces/embedding_in_tk_sgskip.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121

2222
fig = Figure(figsize=(5, 4), dpi=100)
2323
t = np.arange(0, 3, .01)
24-
fig.add_subplot(111).plot(t, 2 * np.sin(2 * np.pi * t))
24+
fig.add_subplot().plot(t, 2 * np.sin(2 * np.pi * t))
2525

2626
canvas = FigureCanvasTkAgg(fig, master=root) # A tk.DrawingArea.
2727
canvas.draw()

examples/user_interfaces/embedding_in_wx2_sgskip.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ def __init__(self):
2323
super().__init__(None, -1, 'CanvasFrame', size=(550, 350))
2424

2525
self.figure = Figure()
26-
self.axes = self.figure.add_subplot(111)
26+
self.axes = self.figure.add_subplot()
2727
t = np.arange(0.0, 3.0, 0.01)
2828
s = np.sin(2 * np.pi * t)
2929

examples/user_interfaces/embedding_in_wx3_sgskip.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ def __init__(self, parent):
5454
self.Fit()
5555

5656
def init_plot_data(self):
57-
ax = self.fig.add_subplot(111)
57+
ax = self.fig.add_subplot()
5858

5959
x = np.arange(120.0) * 2 * np.pi / 60.0
6060
y = np.arange(100.0) * 2 * np.pi / 50.0

examples/user_interfaces/embedding_in_wx4_sgskip.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ def __init__(self):
4444
super().__init__(None, -1, 'CanvasFrame', size=(550, 350))
4545

4646
self.figure = Figure(figsize=(5, 4), dpi=100)
47-
self.axes = self.figure.add_subplot(111)
47+
self.axes = self.figure.add_subplot()
4848
t = np.arange(0.0, 3.0, 0.01)
4949
s = np.sin(2 * np.pi * t)
5050

examples/user_interfaces/embedding_webagg_sgskip.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ def create_figure():
3939
Creates a simple example figure.
4040
"""
4141
fig = Figure()
42-
ax = fig.add_subplot(111)
42+
ax = fig.add_subplot()
4343
t = np.arange(0.0, 3.0, 0.01)
4444
s = np.sin(2 * np.pi * t)
4545
ax.plot(t, s)

examples/user_interfaces/gtk_spreadsheet_sgskip.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ def __init__(self):
5252

5353
self.canvas = FigureCanvas(fig) # a Gtk.DrawingArea
5454
vbox.pack_start(self.canvas, True, True, 0)
55-
ax = fig.add_subplot(111)
55+
ax = fig.add_subplot()
5656
self.line, = ax.plot(self.data[0, :], 'go') # plot the first row
5757

5858
self.treeview.connect('row-activated', self.plot_row)

examples/user_interfaces/mathtext_wx_sgskip.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ def __init__(self, parent, title):
4343
super().__init__(parent, -1, title, size=(550, 350))
4444

4545
self.figure = Figure()
46-
self.axes = self.figure.add_subplot(111)
46+
self.axes = self.figure.add_subplot()
4747

4848
self.canvas = FigureCanvas(self, -1, self.figure)
4949

examples/user_interfaces/mpl_with_glade3_sgskip.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ def main():
3232

3333
# Start of Matplotlib specific code
3434
figure = Figure(figsize=(8, 6), dpi=71)
35-
axis = figure.add_subplot(111)
35+
axis = figure.add_subplot()
3636
t = np.arange(0.0, 3.0, 0.01)
3737
s = np.sin(2*np.pi*t)
3838
axis.plot(t, s)

examples/user_interfaces/wxcursor_demo_sgskip.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ def __init__(self, ):
1919
super().__init__(None, -1, 'CanvasFrame', size=(550, 350))
2020

2121
self.figure = Figure()
22-
self.axes = self.figure.add_subplot(111)
22+
self.axes = self.figure.add_subplot()
2323
t = np.arange(0.0, 3.0, 0.01)
2424
s = np.sin(2*np.pi*t)
2525

examples/widgets/cursor.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
np.random.seed(19680801)
1414

1515
fig = plt.figure(figsize=(8, 6))
16-
ax = fig.add_subplot(111, facecolor='#FFFFCC')
16+
ax = fig.add_subplot(facecolor='#FFFFCC')
1717

1818
x, y = 4*(np.random.rand(2, 100) - .5)
1919
ax.plot(x, y, 'o')

lib/matplotlib/figure.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1368,7 +1368,7 @@ def add_subplot(self, *args, **kwargs):
13681368
if not args:
13691369
args = (1, 1, 1)
13701370
# Normalize correct ijk values to (i, j, k) here so that
1371-
# add_subplot(111) == add_subplot(1, 1, 1). Invalid values will
1371+
# add_subplot(211) == add_subplot(2, 1, 1). Invalid values will
13721372
# trigger errors later (via SubplotSpec._from_subplot_args).
13731373
if (len(args) == 1 and isinstance(args[0], Integral)
13741374
and 100 <= args[0] <= 999):

0 commit comments

Comments
 (0)