Skip to content

Change *subplot(111, ...) to *subplot(...) as 111 is the default. #18552

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
Sep 24, 2020
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
2 changes: 1 addition & 1 deletion examples/animation/double_pendulum.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ def derivs(state, t):
y2 = -L2*cos(y[:, 2]) + y1

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

Expand Down
2 changes: 1 addition & 1 deletion examples/animation/unchained.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
fig = plt.figure(figsize=(8, 8), facecolor='black')

# Add a subplot with no frame
ax = plt.subplot(111, frameon=False)
ax = plt.subplot(frameon=False)

# Generate random data
data = np.random.uniform(0, 1, (64, 75))
Expand Down
2 changes: 1 addition & 1 deletion examples/axes_grid1/simple_colorbar.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
from mpl_toolkits.axes_grid1 import make_axes_locatable
import numpy as np

ax = plt.subplot(111)
ax = plt.subplot()
im = ax.imshow(np.arange(100).reshape((10, 10)))

# create an axes on the right side of ax. The width of cax will be 5%
Expand Down
2 changes: 1 addition & 1 deletion examples/event_handling/trifinder_event_demo.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ def on_mouse_move(event):
trifinder = triang.get_trifinder()

# Setup plot and callbacks.
plt.subplot(111, aspect='equal')
plt.subplot(aspect='equal')
plt.triplot(triang, 'bo-')
polygon = Polygon([[0, 0], [0, 0]], facecolor='y') # dummy data for (xs, ys)
update_polygon(-1)
Expand Down
2 changes: 1 addition & 1 deletion examples/misc/agg_buffer_to_array.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,6 @@

# now display the array X as an Axes in a new figure
fig2 = plt.figure()
ax2 = fig2.add_subplot(111, frameon=False)
ax2 = fig2.add_subplot(frameon=False)
ax2.imshow(X)
plt.show()
4 changes: 2 additions & 2 deletions examples/misc/custom_projection.py
Original file line number Diff line number Diff line change
Expand Up @@ -370,7 +370,7 @@ class HammerAxes(GeoAxes):

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

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

Expand Down
1 change: 0 additions & 1 deletion examples/misc/customize_rc.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ def set_pub():
Then as you are working interactively, you just need to do::

>>> set_pub()
>>> subplot(111)
>>> plot([1, 2, 3])
>>> savefig('myfig')
>>> rcdefaults() # restore the defaults
Expand Down
2 changes: 1 addition & 1 deletion examples/mplot3d/bars3d.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@


fig = plt.figure()
ax = fig.add_subplot(111, projection='3d')
ax = fig.add_subplot(projection='3d')

colors = ['r', 'g', 'b', 'y']
yticks = [3, 2, 1, 0]
Expand Down
2 changes: 1 addition & 1 deletion examples/mplot3d/hist3d.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@


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

Expand Down
2 changes: 1 addition & 1 deletion examples/mplot3d/pathpatch3d.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ def text3d(ax, xyz, s, zdir="z", size=None, angle=0, usetex=False, **kwargs):


fig = plt.figure()
ax = fig.add_subplot(111, projection='3d')
ax = fig.add_subplot(projection='3d')

# Draw a circle on the x=0 'wall'
p = Circle((5, 5), 3)
Expand Down
2 changes: 1 addition & 1 deletion examples/mplot3d/rotate_axes3d_sgskip.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
import matplotlib.pyplot as plt

fig = plt.figure()
ax = fig.add_subplot(111, projection='3d')
ax = fig.add_subplot(projection='3d')

# load some test data for demonstration and plot a wireframe
X, Y, Z = axes3d.get_test_data(0.1)
Expand Down
2 changes: 1 addition & 1 deletion examples/mplot3d/scatter3d.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ def randrange(n, vmin, vmax):
return (vmax - vmin)*np.random.rand(n) + vmin

fig = plt.figure()
ax = fig.add_subplot(111, projection='3d')
ax = fig.add_subplot(projection='3d')

n = 100

Expand Down
2 changes: 1 addition & 1 deletion examples/mplot3d/surface3d_2.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@


fig = plt.figure()
ax = fig.add_subplot(111, projection='3d')
ax = fig.add_subplot(projection='3d')

# Make data
u = np.linspace(0, 2 * np.pi, 100)
Expand Down
2 changes: 1 addition & 1 deletion examples/mplot3d/surface3d_radial.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@


fig = plt.figure()
ax = fig.add_subplot(111, projection='3d')
ax = fig.add_subplot(projection='3d')

# Create the mesh in polar coordinates and compute corresponding Z.
r = np.linspace(0, 1.25, 50)
Expand Down
2 changes: 1 addition & 1 deletion examples/mplot3d/wire3d.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@


fig = plt.figure()
ax = fig.add_subplot(111, projection='3d')
ax = fig.add_subplot(projection='3d')

# Grab some test data.
X, Y, Z = axes3d.get_test_data(0.05)
Expand Down
2 changes: 1 addition & 1 deletion examples/mplot3d/wire3d_animation_sgskip.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ def generate(X, Y, phi):


fig = plt.figure()
ax = fig.add_subplot(111, projection='3d')
ax = fig.add_subplot(projection='3d')

# Make the X, Y meshgrid.
xs = np.linspace(-1, 1, 50)
Expand Down
2 changes: 1 addition & 1 deletion examples/pie_and_polar_charts/polar_bar.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
width = np.pi / 4 * np.random.rand(N)
colors = plt.cm.viridis(radii / 10.)

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

plt.show()
Expand Down
6 changes: 3 additions & 3 deletions examples/pie_and_polar_charts/polar_scatter.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
colors = theta

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

###############################################################################
Expand All @@ -33,7 +33,7 @@
# rotate the plot.

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

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

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

ax.set_thetamin(45)
Expand Down
2 changes: 1 addition & 1 deletion examples/pyplots/annotation_polar.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
import matplotlib.pyplot as plt

fig = plt.figure()
ax = fig.add_subplot(111, polar=True)
ax = fig.add_subplot(polar=True)
r = np.arange(0, 1, 0.001)
theta = 2 * 2*np.pi * r
line, = ax.plot(theta, r, color='#ee8d18', lw=3)
Expand Down
2 changes: 1 addition & 1 deletion examples/pyplots/text_commands.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
fig = plt.figure()
fig.suptitle('bold figure suptitle', fontsize=14, fontweight='bold')

ax = fig.add_subplot(111)
ax = fig.add_subplot()
fig.subplots_adjust(top=0.85)
ax.set_title('axes title')

Expand Down
2 changes: 1 addition & 1 deletion examples/pyplots/whats_new_98_4_legend.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
import numpy as np


ax = plt.subplot(111)
ax = plt.subplot()
t1 = np.arange(0.0, 1.0, 0.01)
for n in [1, 2, 3, 4]:
plt.plot(t1, t1**n, label=f"n={n}")
Expand Down
5 changes: 2 additions & 3 deletions examples/specialty_plots/skewt.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,8 +79,7 @@ def _adjust_location(self):
# spines and axes instances as appropriate.
class SkewXAxes(Axes):
# The projection must specify a name. This will be used be the
# user to select the projection, i.e. ``subplot(111,
# projection='skewx')``.
# user to select the projection, i.e. ``subplot(projection='skewx')``.
name = 'skewx'

def _init_axis(self):
Expand Down Expand Up @@ -236,7 +235,7 @@ def upper_xlim(self):

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

plt.grid(True)

Expand Down
8 changes: 4 additions & 4 deletions examples/subplots_axes_and_figures/geo_demo.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,28 +14,28 @@
###############################################################################

plt.figure()
plt.subplot(111, projection="aitoff")
plt.subplot(projection="aitoff")
plt.title("Aitoff")
plt.grid(True)

###############################################################################

plt.figure()
plt.subplot(111, projection="hammer")
plt.subplot(projection="hammer")
plt.title("Hammer")
plt.grid(True)

###############################################################################

plt.figure()
plt.subplot(111, projection="lambert")
plt.subplot(projection="lambert")
plt.title("Lambert")
plt.grid(True)

###############################################################################

plt.figure()
plt.subplot(111, projection="mollweide")
plt.subplot(projection="mollweide")
plt.title("Mollweide")
plt.grid(True)

Expand Down
2 changes: 1 addition & 1 deletion examples/user_interfaces/canvasagg.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
canvas = FigureCanvasAgg(fig)

# Do some plotting.
ax = fig.add_subplot(111)
ax = fig.add_subplot()
ax.plot([1, 2, 3])

# Option 1: Save the figure to a file; can also be a file-like object (BytesIO,
Expand Down
2 changes: 1 addition & 1 deletion examples/user_interfaces/embedding_in_gtk3_sgskip.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
win.set_title("Embedding in GTK")

fig = Figure(figsize=(5, 4), dpi=100)
ax = fig.add_subplot(111)
ax = fig.add_subplot()
t = np.arange(0.0, 3.0, 0.01)
s = np.sin(2*np.pi*t)
ax.plot(t, s)
Expand Down
2 changes: 1 addition & 1 deletion examples/user_interfaces/embedding_in_tk_sgskip.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@

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

canvas = FigureCanvasTkAgg(fig, master=root) # A tk.DrawingArea.
canvas.draw()
Expand Down
2 changes: 1 addition & 1 deletion examples/user_interfaces/embedding_in_wx2_sgskip.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ def __init__(self):
super().__init__(None, -1, 'CanvasFrame', size=(550, 350))

self.figure = Figure()
self.axes = self.figure.add_subplot(111)
self.axes = self.figure.add_subplot()
t = np.arange(0.0, 3.0, 0.01)
s = np.sin(2 * np.pi * t)

Expand Down
2 changes: 1 addition & 1 deletion examples/user_interfaces/embedding_in_wx3_sgskip.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ def __init__(self, parent):
self.Fit()

def init_plot_data(self):
ax = self.fig.add_subplot(111)
ax = self.fig.add_subplot()

x = np.arange(120.0) * 2 * np.pi / 60.0
y = np.arange(100.0) * 2 * np.pi / 50.0
Expand Down
2 changes: 1 addition & 1 deletion examples/user_interfaces/embedding_in_wx4_sgskip.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ def __init__(self):
super().__init__(None, -1, 'CanvasFrame', size=(550, 350))

self.figure = Figure(figsize=(5, 4), dpi=100)
self.axes = self.figure.add_subplot(111)
self.axes = self.figure.add_subplot()
t = np.arange(0.0, 3.0, 0.01)
s = np.sin(2 * np.pi * t)

Expand Down
2 changes: 1 addition & 1 deletion examples/user_interfaces/embedding_webagg_sgskip.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ def create_figure():
Creates a simple example figure.
"""
fig = Figure()
ax = fig.add_subplot(111)
ax = fig.add_subplot()
t = np.arange(0.0, 3.0, 0.01)
s = np.sin(2 * np.pi * t)
ax.plot(t, s)
Expand Down
2 changes: 1 addition & 1 deletion examples/user_interfaces/gtk_spreadsheet_sgskip.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ def __init__(self):

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

self.treeview.connect('row-activated', self.plot_row)
Expand Down
2 changes: 1 addition & 1 deletion examples/user_interfaces/mathtext_wx_sgskip.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ def __init__(self, parent, title):
super().__init__(parent, -1, title, size=(550, 350))

self.figure = Figure()
self.axes = self.figure.add_subplot(111)
self.axes = self.figure.add_subplot()

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

Expand Down
2 changes: 1 addition & 1 deletion examples/user_interfaces/mpl_with_glade3_sgskip.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ def main():

# Start of Matplotlib specific code
figure = Figure(figsize=(8, 6), dpi=71)
axis = figure.add_subplot(111)
axis = figure.add_subplot()
t = np.arange(0.0, 3.0, 0.01)
s = np.sin(2*np.pi*t)
axis.plot(t, s)
Expand Down
2 changes: 1 addition & 1 deletion examples/user_interfaces/wxcursor_demo_sgskip.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ def __init__(self, ):
super().__init__(None, -1, 'CanvasFrame', size=(550, 350))

self.figure = Figure()
self.axes = self.figure.add_subplot(111)
self.axes = self.figure.add_subplot()
t = np.arange(0.0, 3.0, 0.01)
s = np.sin(2*np.pi*t)

Expand Down
2 changes: 1 addition & 1 deletion examples/widgets/cursor.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
np.random.seed(19680801)

fig = plt.figure(figsize=(8, 6))
ax = fig.add_subplot(111, facecolor='#FFFFCC')
ax = fig.add_subplot(facecolor='#FFFFCC')

x, y = 4*(np.random.rand(2, 100) - .5)
ax.plot(x, y, 'o')
Expand Down
2 changes: 1 addition & 1 deletion lib/matplotlib/figure.py
Original file line number Diff line number Diff line change
Expand Up @@ -1368,7 +1368,7 @@ def add_subplot(self, *args, **kwargs):
if not args:
args = (1, 1, 1)
# Normalize correct ijk values to (i, j, k) here so that
# add_subplot(111) == add_subplot(1, 1, 1). Invalid values will
# add_subplot(211) == add_subplot(2, 1, 1). Invalid values will
# trigger errors later (via SubplotSpec._from_subplot_args).
if (len(args) == 1 and isinstance(args[0], Integral)
and 100 <= args[0] <= 999):
Expand Down
Loading