Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Gridspec doc fixes #9604

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 2 commits into from
Oct 28, 2017
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
40 changes: 32 additions & 8 deletions 40 lib/matplotlib/pyplot.py
Original file line number Diff line number Diff line change
Expand Up @@ -1186,18 +1186,42 @@ def subplots(nrows=1, ncols=1, sharex=False, sharey=False, squeeze=True,

def subplot2grid(shape, loc, rowspan=1, colspan=1, fig=None, **kwargs):
"""
Create a subplot in a grid. The grid is specified by *shape*, at
location of *loc*, spanning *rowspan*, *colspan* cells in each
direction. The index for loc is 0-based. The current figure will
be used unless *fig* is specified. ::
Create an axis at specific location inside a regular grid.

subplot2grid(shape, loc, rowspan=1, colspan=1)
Parameters
----------
shape : sequence of 2 ints
Shape of grid in which to place axis.
First entry is number of rows, second entry is number of columns.

loc : sequence of 2 ints
Location to place axis within grid.
First entry is row number, second entry is column number.

rowspan : int
Number of rows for the axis to span to the right.

colspan : int
Number of columns for the axis to span downwards.

fig : `Figure`, optional
Figure to place axis in. Defaults to current figure.

**kwargs
Additional keyword arguments are handed to `add_subplot`.


Notes
-----
The following call ::

subplot2grid(shape, loc, rowspan=1, colspan=1)

is identical to ::

gridspec=GridSpec(shape[0], shape[1])
subplotspec=gridspec.new_subplotspec(loc, rowspan, colspan)
subplot(subplotspec)
gridspec=GridSpec(shape[0], shape[1])
subplotspec=gridspec.new_subplotspec(loc, rowspan, colspan)
subplot(subplotspec)
"""

if fig is None:
Expand Down
6 changes: 3 additions & 3 deletions 6 tutorials/intermediate/gridspec.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,13 +75,13 @@

# A GridSpec instance provides array-like (2d or 1d) indexing that
# returns the SubplotSpec instance. For a SubplotSpec that spans multiple
# cells, use slice. ::
# cells, use slice.

ax2 = plt.subplot(gs[1, :-1])
ax3 = plt.subplot(gs[1:, -1])

###############################################################################
# The above example becomes ::
# The above example becomes

fig = plt.figure()
gs = gridspec.GridSpec(3, 3)
Expand All @@ -96,7 +96,7 @@
# ======================
#
# When a GridSpec is explicitly used, you can adjust the layout
# parameters of subplots that are created from the GridSpec. ::
# parameters of subplots that are created from the GridSpec.

fig = plt.figure()
gs1 = gridspec.GridSpec(3, 3)
Expand Down
Morty Proxy This is a proxified and sanitized view of the page, visit original site.