Skip to content

DOC: remove examples of subplot(123) from docs #17335

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

Closed
wants to merge 7 commits into from
Closed
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 doc/api/prev_api_changes/api_changes_3.1.0.rst
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ back on the linear `.AutoLocator` to pick reasonable tick positions.
`.Figure.add_subplot` with no arguments
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Calling `.Figure.add_subplot()` with no positional arguments used to do
nothing; this now is equivalent to calling ``add_subplot(111)`` instead.
nothing; this now is equivalent to calling ``add_subplot(1, 1, 1)`` instead.

`~.Axes.bxp` and rcparams
~~~~~~~~~~~~~~~~~~~~~~~~~
Expand Down
2 changes: 1 addition & 1 deletion doc/api/prev_api_changes/api_changes_3.2.0/behavior.rst
Original file line number Diff line number Diff line change
Expand Up @@ -306,7 +306,7 @@ mplot3d auto-registration
`mpl_toolkits.mplot3d` is always registered by default now. It is no
longer necessary to import mplot3d to create 3d axes with ::

ax = fig.add_subplot(111, projection="3d")
ax = fig.add_subplot(1, 1, 1, projection="3d")

`.SymLogNorm` now has a *base* parameter
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Expand Down
2 changes: 1 addition & 1 deletion doc/devel/documenting_mpl.rst
Original file line number Diff line number Diff line change
Expand Up @@ -820,7 +820,7 @@ example is generated from
s = 1 + np.sin(2 * np.pi * t)

# Note that using plt.subplots below is equivalent to using
# fig = plt.figure and then ax = fig.add_subplot(111)
# fig = plt.figure and then ax = fig.add_subplot()
fig, ax = plt.subplots()
ax.plot(t, s)

Expand Down
8 changes: 4 additions & 4 deletions doc/faq/howto_faq.rst
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ any property on them directly (*facecolor*, *edgecolor*, *linewidth*,

fig = plt.figure()
fig.patch.set_alpha(0.5)
ax = fig.add_subplot(111)
ax = fig.add_subplot()
ax.patch.set_alpha(0.5)

If you need *all* the figure elements to be transparent, there is
Expand Down Expand Up @@ -177,7 +177,7 @@ labels::

fig = plt.figure()
fig.subplots_adjust(bottom=0.2)
ax = fig.add_subplot(111)
ax = fig.add_subplot()

You can control the defaults for these parameters in your
:file:`matplotlibrc` file; see :doc:`/tutorials/introductory/customizing`. For
Expand Down Expand Up @@ -368,7 +368,7 @@ The Axes property :meth:`~matplotlib.axes.Axes.set_aspect` controls the
aspect ratio of the axes. You can set it to be 'auto', 'equal', or
some ratio which controls the ratio::

ax = fig.add_subplot(111, aspect='equal')
ax = fig.add_subplot(1, 1, 1, aspect='equal')

.. only:: html

Expand Down Expand Up @@ -400,7 +400,7 @@ locators as desired because the two axes are independent.
import matplotlib.pyplot as plt

fig = plt.figure()
ax1 = fig.add_subplot(111)
ax1 = fig.add_subplot()
t = np.arange(0.01, 10.0, 0.01)
s1 = np.exp(t)
ax1.plot(t, s1, 'b-')
Expand Down
18 changes: 9 additions & 9 deletions doc/users/event_handling.rst
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ is created every time a mouse is pressed::
self.line.figure.canvas.draw()

fig = plt.figure()
ax = fig.add_subplot(111)
ax = fig.add_subplot()
ax.set_title('click to build line segments')
line, = ax.plot([0], [0]) # empty line
linebuilder = LineBuilder(line)
Expand Down Expand Up @@ -230,7 +230,7 @@ Here is the solution::
self.rect.figure.canvas.mpl_disconnect(self.cidmotion)

fig = plt.figure()
ax = fig.add_subplot(111)
ax = fig.add_subplot()
rects = ax.bar(range(10), 20*np.random.rand(10))
drs = []
for rect in rects:
Expand Down Expand Up @@ -334,7 +334,7 @@ Extra credit solution::
self.rect.figure.canvas.mpl_disconnect(self.cidmotion)

fig = plt.figure()
ax = fig.add_subplot(111)
ax = fig.add_subplot()
rects = ax.bar(range(10), 20*np.random.rand(10))
drs = []
for rect in rects:
Expand Down Expand Up @@ -383,8 +383,8 @@ background that the mouse is over::

fig1 = plt.figure()
fig1.suptitle('mouse hover over figure or axes to trigger events')
ax1 = fig1.add_subplot(211)
ax2 = fig1.add_subplot(212)
ax1 = fig1.add_subplot(2, 1, 1)
ax2 = fig1.add_subplot(2, 1, 2)

fig1.canvas.mpl_connect('figure_enter_event', enter_figure)
fig1.canvas.mpl_connect('figure_leave_event', leave_figure)
Expand All @@ -393,8 +393,8 @@ background that the mouse is over::

fig2 = plt.figure()
fig2.suptitle('mouse hover over figure or axes to trigger events')
ax1 = fig2.add_subplot(211)
ax2 = fig2.add_subplot(212)
ax1 = fig2.add_subplot(2, 1, 1)
ax2 = fig2.add_subplot(2, 1, 2)

fig2.canvas.mpl_connect('figure_enter_event', enter_figure)
fig2.canvas.mpl_connect('figure_leave_event', leave_figure)
Expand Down Expand Up @@ -493,7 +493,7 @@ properties of the line. Here is the code::
import matplotlib.pyplot as plt

fig = plt.figure()
ax = fig.add_subplot(111)
ax = fig.add_subplot()
ax.set_title('click on points')

line, = ax.plot(np.random.rand(100), 'o', picker=5) # 5 points tolerance
Expand Down Expand Up @@ -538,7 +538,7 @@ Exercise solution::
ys = np.std(X, axis=1)

fig = plt.figure()
ax = fig.add_subplot(111)
ax = fig.add_subplot()
ax.set_title('click on point to plot time series')
line, = ax.plot(xs, ys, 'o', picker=5) # 5 points tolerance

Expand Down
2 changes: 1 addition & 1 deletion doc/users/history.rst
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ Matplotlib's original logo (2003 -- 2008).
# 0.0005 is the sample interval
t = 0.0005 * np.arange(len(x))
plt.figure(1, figsize=(7, 1), dpi=100)
ax = plt.subplot(111, facecolor='y')
ax = plt.subplot(1, 1, 1, facecolor='y')
plt.plot(t, x)
plt.text(0.5, 0.5, 'matplotlib', color='r',
fontsize=40, fontname=['Courier', 'DejaVu Sans Mono'],
Expand Down
2 changes: 1 addition & 1 deletion doc/users/navigation_toolbar.rst
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ example code for GTK+ 3::
win.add(vbox)

fig = Figure(figsize=(5,4), dpi=100)
ax = fig.add_subplot(111)
ax = fig.add_subplot()
ax.plot([1,2,3])

canvas = FigureCanvas(fig) # a Gtk.DrawingArea
Expand Down
6 changes: 3 additions & 3 deletions doc/users/prev_whats_new/changelog.rst
Original file line number Diff line number Diff line change
Expand Up @@ -290,7 +290,7 @@ the `API changes <../../api/api_changes.html>`_.
Uses a default range(n) when the first arg not provided.
Damon McDougall

2012-11-09 Make plt.subplot() without arguments act as subplot(111) - PI
2012-11-09 Make plt.subplot() without arguments act as subplot(1, 1, 1) - PI

2012-11-08 Replaced plt.figure and plt.subplot calls by the newer, more
convenient single call to plt.subplots() in the documentation
Expand Down Expand Up @@ -2289,8 +2289,8 @@ the `API changes <../../api/api_changes.html>`_.
fig1 = figure()
fig2 = figure()

ax1 = fig1.add_subplot(111)
ax2 = fig2.add_subplot(111, sharex=ax1, sharey=ax1)
ax1 = fig1.add_subplot()
ax2 = fig2.add_subplot(1, 1, 1, sharex=ax1, sharey=ax1)

- linestyles now include steps-pre, steps-post and
steps-mid. The old step still works and is equivalent to
Expand Down
2 changes: 1 addition & 1 deletion examples/animation/double_pendulum_sgskip.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ def derivs(state, t):
y2 = -L2*cos(y[:, 2]) + y1

fig = plt.figure()
ax = fig.add_subplot(111, autoscale_on=False, xlim=(-2, 2), ylim=(-2, 2))
ax = fig.add_subplot(1, 1, 1, autoscale_on=False, xlim=(-2, 2), ylim=(-2, 2))
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(1, 1, 1, frameon=False)

# Generate random data
data = np.random.uniform(0, 1, (64, 75))
Expand Down
8 changes: 4 additions & 4 deletions examples/axes_grid1/demo_axes_grid.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ def demo_simple_grid(fig):
A grid of 2x2 images with 0.05 inch pad between images and only
the lower-left axes is labeled.
"""
grid = ImageGrid(fig, 141, # similar to subplot(141)
grid = ImageGrid(fig, 141, # similar to subplot(1, 4, 1)
nrows_ncols=(2, 2),
axes_pad=0.05,
label_mode="1",
Expand All @@ -44,7 +44,7 @@ def demo_grid_with_single_cbar(fig):
"""
A grid of 2x2 images with a single colorbar
"""
grid = ImageGrid(fig, 142, # similar to subplot(142)
grid = ImageGrid(fig, 142, # similar to subplot(1, 4, 2)
nrows_ncols=(2, 2),
axes_pad=0.0,
share_all=True,
Expand All @@ -70,7 +70,7 @@ def demo_grid_with_each_cbar(fig):
"""
A grid of 2x2 images. Each image has its own colorbar.
"""
grid = ImageGrid(fig, 143, # similar to subplot(143)
grid = ImageGrid(fig, 143, # similar to subplot(1, 4, 3)
nrows_ncols=(2, 2),
axes_pad=0.1,
label_mode="1",
Expand All @@ -95,7 +95,7 @@ def demo_grid_with_each_cbar_labelled(fig):
"""
A grid of 2x2 images. Each image has its own colorbar.
"""
grid = ImageGrid(fig, 144, # similar to subplot(144)
grid = ImageGrid(fig, 144, # similar to subplot(1, 4, 4)
nrows_ncols=(2, 2),
axes_pad=(0.45, 0.15),
label_mode="1",
Expand Down
2 changes: 1 addition & 1 deletion examples/axes_grid1/demo_axes_grid2.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ def add_inner_title(ax, title, loc, **kwargs):
extent = extent[0], extent[1]/3., extent[2], extent[3]

# *** Demo 1: colorbar at each axes ***
grid = ImageGrid(fig, 211, # similar to subplot(211)
grid = ImageGrid(fig, 211, # similar to subplot(2, 1, 1)
nrows_ncols=(1, 3),
axes_pad=0.05,
label_mode="1",
Expand Down
4 changes: 2 additions & 2 deletions examples/axes_grid1/demo_edge_colorbar.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ def demo_bottom_cbar(fig):
"""
A grid of 2x2 images with a colorbar for each column.
"""
grid = AxesGrid(fig, 121, # similar to subplot(121)
grid = AxesGrid(fig, 121, # similar to subplot(1, 2, 1)
nrows_ncols=(2, 2),
axes_pad=0.10,
share_all=True,
Expand Down Expand Up @@ -59,7 +59,7 @@ def demo_right_cbar(fig):
"""
A grid of 2x2 images. Each row has its own colorbar.
"""
grid = AxesGrid(fig, 122, # similar to subplot(122)
grid = AxesGrid(fig, 122, # similar to subplot(1, 2, 2)
nrows_ncols=(2, 2),
axes_pad=0.10,
label_mode="1",
Expand Down
10 changes: 5 additions & 5 deletions examples/axes_grid1/inset_locator_demo.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@
#

fig = plt.figure(figsize=[5.5, 2.8])
ax = fig.add_subplot(121)
ax = fig.add_subplot(1, 2, 1)

# We use the axes transform as bbox_transform. Therefore the bounding box
# needs to be specified in axes coordinates ((0, 0) is the lower left corner
Expand Down Expand Up @@ -80,10 +80,10 @@
# Note how the two following insets are created at the same positions, one by
# use of the default parent axes' bbox and the other via a bbox in axes
# coordinates and the respective transform.
ax2 = fig.add_subplot(222)
ax2 = fig.add_subplot(2, 2, 2)
axins2 = inset_axes(ax2, width="30%", height="50%")

ax3 = fig.add_subplot(224)
ax3 = fig.add_subplot(2, 2, 4)
axins3 = inset_axes(ax3, width="100%", height="100%",
bbox_to_anchor=(.7, .5, .3, .5),
bbox_transform=ax3.transAxes)
Expand All @@ -108,7 +108,7 @@
#

fig = plt.figure(figsize=[5.5, 2.8])
ax = fig.add_subplot(131)
ax = fig.add_subplot(1, 3, 1)

# Create an inset outside the axes
axins = inset_axes(ax, width="100%", height="100%",
Expand All @@ -124,7 +124,7 @@
bbox_transform=ax.transAxes, loc=3, borderpad=0)


ax2 = fig.add_subplot(133)
ax2 = fig.add_subplot(1, 3, 3)
ax2.set_xscale("log")
ax2.set(xlim=(1e-6, 1e6), ylim=(-2, 6))

Expand Down
2 changes: 1 addition & 1 deletion examples/axes_grid1/parasite_simple.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
from mpl_toolkits.axes_grid1 import host_subplot
import matplotlib.pyplot as plt

host = host_subplot(111)
host = host_subplot(1, 1, 1)

par = host.twinx()

Expand Down
2 changes: 1 addition & 1 deletion examples/axes_grid1/simple_axesgrid.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
im4 = np.fliplr(im2)

fig = plt.figure(figsize=(4., 4.))
grid = ImageGrid(fig, 111, # similar to subplot(111)
grid = ImageGrid(fig, 111, # similar to subplot(1, 1, 1)
nrows_ncols=(2, 2), # creates 2x2 grid of axes
axes_pad=0.1, # pad between axes in inch.
)
Expand Down
2 changes: 1 addition & 1 deletion examples/axes_grid1/simple_axesgrid2.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ def get_demo_image():


fig = plt.figure(figsize=(5.5, 3.5))
grid = ImageGrid(fig, 111, # similar to subplot(111)
grid = ImageGrid(fig, 111, # similar to subplot(1, 1, 1)
nrows_ncols=(1, 3),
axes_pad=0.1,
label_mode="L",
Expand Down
2 changes: 1 addition & 1 deletion examples/axes_grid1/simple_axisline4.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
from mpl_toolkits.axes_grid1 import host_subplot
import numpy as np

ax = host_subplot(111)
ax = host_subplot(1, 1, 1)
xx = np.arange(0, 2*np.pi, 0.01)
ax.plot(xx, np.sin(xx))

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(1, 1, 1)
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/axisartist/demo_parasite_axes2.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
from mpl_toolkits import axisartist
import matplotlib.pyplot as plt

host = host_subplot(111, axes_class=axisartist.Axes)
host = host_subplot(1, 1, 1, axes_class=axisartist.Axes)
plt.subplots_adjust(right=0.75)

par1 = host.twinx()
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(1, 1, 1, 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/lines_bars_and_markers/eventcollection_demo.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@

# plot the data
fig = plt.figure()
ax = fig.add_subplot(1, 1, 1)
ax = fig.add_subplot()
ax.plot(xdata1, ydata1, color='tab:blue')
ax.plot(xdata2, ydata2, color='tab:orange')

Expand Down
8 changes: 4 additions & 4 deletions examples/lines_bars_and_markers/psd_demo.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,9 @@
cnse = cnse[:len(t)]
s = 0.1 * np.sin(2 * np.pi * t) + cnse

plt.subplot(211)
plt.subplot(2, 1, 1)
plt.plot(t, s)
plt.subplot(212)
plt.subplot(2, 1, 2)
plt.psd(s, 512, 1 / dt)

plt.show()
Expand All @@ -44,9 +44,9 @@
# cnse = cnse(1:length(t));
# s = 0.1*sin(2*pi*t) + cnse;
#
# subplot(211)
# subplot(2, 1, 1)
# plot(t, s)
# subplot(212)
# subplot(2, 1, 2)
# psd(s, 512, 1/dt)
#
# Below we'll show a slightly more complex example that demonstrates
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(1, 1, 1, frameon=False)
ax2.imshow(X)
plt.show()
Loading