Skip to content
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

subplot docstring improvement (re #300) #953

Closed
wants to merge 8 commits into from
9 changes: 5 additions & 4 deletions boilerplate.py
Expand Up @@ -47,15 +47,15 @@ def %(func)s(%(argspec)s):
%(ax)s = gca()
# allow callers to override the hold state by passing hold=True|False
%(washold)s = %(ax)s.ishold()
%(sethold)s
%(sethold)s
if hold is not None:
%(ax)s.hold(hold)
try:
%(ret)s = %(ax)s.%(func)s(%(call)s)
draw_if_interactive()
finally:
%(ax)s.hold(%(washold)s)
%(mappable)s
%(mappable)s
return %(ret)s
"""

Expand Down Expand Up @@ -199,7 +199,7 @@ def format_value(value):
# For some commands, an additional line is needed to set the
# color map
if func in cmappable:
mappable = cmappable[func] % locals()
mappable = ' ' + cmappable[func] % locals()
else:
mappable = ''

Expand Down Expand Up @@ -232,7 +232,7 @@ def format_value(value):
# argument in front of it since it would gobble one of the
# arguments the user means to pass via *args)
if varargs:
sethold = "hold = %(varkw)s.pop('hold', None)" % locals()
sethold = " hold = %(varkw)s.pop('hold', None)" % locals()
elif fmt is PLOT_TEMPLATE:
args.append('hold')
defaults = defaults + (None,)
Expand Down Expand Up @@ -306,6 +306,7 @@ def build_pyplot():
pyplot.write('\n')

pyplot.writelines(boilerplate_gen())
pyplot.write('\n')


if __name__ == '__main__':
Expand Down
2 changes: 1 addition & 1 deletion examples/pylab_examples/histogram_demo_extended.py
Expand Up @@ -111,7 +111,7 @@
w1 = np.ones_like(x1)
w1[:len(x1)/2] = 0.5
w2 = np.ones_like(x2)
w0[:len(x2)/2] = 0.5
w2[:len(x2)/2] = 0.5



Expand Down
9 changes: 5 additions & 4 deletions lib/matplotlib/axes.py
Expand Up @@ -5320,11 +5320,12 @@ def errorbar(self, x, y, yerr=None, xerr=None,
Optional keyword arguments:

*xerr*/*yerr*: [ scalar | N, Nx1, or 2xN array-like ]
If a scalar number, len(N) array-like object, or an Nx1 array-like
object, errorbars are drawn +/- value.
If a scalar number, len(N) array-like object, or an Nx1
array-like object, errorbars are drawn at +/-value relative
to the data.

If a sequence of shape 2xN, errorbars are drawn at -row1 and
+row2
If a sequence of shape 2xN, errorbars are drawn at -row1
and +row2 relative to the data.

*fmt*: '-'
The plot format symbol. If *fmt* is *None*, only the
Expand Down
2 changes: 1 addition & 1 deletion lib/matplotlib/pylab.py
Expand Up @@ -83,7 +83,7 @@
specgram - a spectrogram plot
spy - plot sparsity pattern using markers or image
stem - make a stem plot
subplot - make a subplot (numrows, numcols, axesnum)
subplot - make a subplot (nrows, ncols, plot_number)
subplots_adjust - change the params controlling the subplot positions of current figure
subplot_tool - launch the subplot configuration tool
suptitle - add a figure title
Expand Down
53 changes: 34 additions & 19 deletions lib/matplotlib/pyplot.py
Expand Up @@ -711,32 +711,47 @@ def gca(**kwargs):

def subplot(*args, **kwargs):
"""
Create a new axes (subplot).
Return a subplot axes positioned by the given grid definition.

Creating axes with::
Typical call signature::

subplot(numRows, numCols, plotNum)
subplot(nrows, ncols, plot_number)

where *plotNum* = 1 is the first plot number and increasing *plotNums*
fill rows first. max(*plotNum*) == *numRows* * *numCols*
Where *nrows* and *ncols* are used to notionally split the figure
into ``nrows * ncols`` sub-axes, and *plot_number* is used to identify
the particular subplot that this function is to create within the notional
grid. *plot_number* starts at 1, increments across rows first and has a
maximum of ``nrows * ncols``.

You can leave out the commas if *numRows* <= *numCols* <=
*plotNum* < 10, as in::
In the case when *nrows*, *ncols* and *plot_number* are all less than 10,
a convenience exists, such that the a 3 digit number can be given instead,
where the hundreds represent *nrows*, the tens represent *ncols* and the
units represent *plot_number*. For instance::

subplot(211) # 2 rows, 1 column, first (upper) plot
subplot(211)

``subplot(111)`` is the default axis.
produces a subaxes in a figure which represents the top plot (i.e. the
first) in a 2 row by 1 column notional grid (no grid actually exists,
but conceptually this is how the returned subplot has been positioned).

New subplots that overlap old will delete the old axes. If you do
not want this behavior, use
:meth:`~matplotlib.figure.Figure.add_subplot` or the
:func:`~matplotlib.pyplot.axes` command. Eg.::
.. note::

from pylab import *
plot([1,2,3]) # implicitly creates subplot(111)
subplot(211) # overlaps, subplot(111) is killed
plot(rand(12), rand(12))
subplot(212, axisbg='y') # creates 2nd subplot with yellow background
Creating a new subplot with a position which is entirely inside a
pre-existing axes will trigger the larger axes to be deleted::

import matplotlib.pyplot as plt
# plot a line, implicitly creating a subplot(111)
plt.plot([1,2,3])
# now create a subplot which represents the top plot of a grid
# with 2 rows and 1 column. Since this subplot will overlap the
# first, the plot (and its axes) previously created, will be removed
plt.subplot(211)
plt.plot(range(12))
plt.subplot(212, axisbg='y') # creates 2nd subplot with yellow background

If you do not want this behavior, use the
:meth:`~matplotlib.figure.Figure.add_subplot` method or the
:func:`~matplotlib.pyplot.axes` function instead.

Keyword arguments:

Expand Down Expand Up @@ -2997,7 +3012,7 @@ def stackplot(x, *args, **kwargs):
draw_if_interactive()
finally:
ax.hold(washold)

return ret

# This function was autogenerated by boilerplate.py. Do not edit as
Expand Down
2 changes: 1 addition & 1 deletion lib/matplotlib/transforms.py
Expand Up @@ -150,7 +150,7 @@ def _invalidate_internal(self, value, invalidating_node):
if self.pass_through or status_changed:
self._invalid = value

for parent in self._parents.itervalues():
for parent in self._parents.values():
parent._invalidate_internal(value=value,
invalidating_node=self)

Expand Down