Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork7.9k
Simplify (quite a bit...) _preprocess_data#10928
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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
Uh oh!
There was an error while loading.Please reload this page.
Changes fromall commits
7b69287
2445465
6e4c5c1
b07377f
434a6a5
File filter
Filter by extension
Conversations
Uh oh!
There was an error while loading.Please reload this page.
Jump to
Uh oh!
There was an error while loading.Please reload this page.
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
Axes methods now raise TypeError instead of RuntimeError on mismatched calls | ||
```````````````````````````````````````````````````````````````````````````` | ||
In certain cases, Axes methods (and pyplot functions) used to raise a | ||
RuntimeError if they were called with a ``data`` kwarg and otherwise mismatched | ||
arguments. They now raise a ``TypeError`` instead. |
Large diffs are not rendered by default.
Uh oh!
There was an error while loading.Please reload this page.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -42,46 +42,6 @@ | ||
rcParams = matplotlib.rcParams | ||
def _make_inset_locator(bounds, trans, parent): | ||
""" | ||
Helper function to locate inset axes, used in | ||
@@ -1153,8 +1113,7 @@ def vlines(self, x, ymin, ymax, colors='k', linestyles='solid', | ||
@_preprocess_data(replace_names=["positions", "lineoffsets", | ||
"linelengths", "linewidths", | ||
"colors", "linestyles"]) | ||
@docstring.dedent_interpd | ||
def eventplot(self, positions, orientation='horizontal', lineoffsets=1, | ||
linelengths=1, linewidths=None, colors=None, | ||
@@ -1368,13 +1327,12 @@ def eventplot(self, positions, orientation='horizontal', lineoffsets=1, | ||
return colls | ||
#### Basic plotting | ||
# Uses a custom implementation of data-kwarg handling in | ||
# _process_plot_var_args. | ||
@docstring.dedent_interpd | ||
def plot(self, *args, scalex=True, scaley=True,data=None,**kwargs): | ||
""" | ||
Plot y versus x as lines and/or markers. | ||
@@ -1485,7 +1443,6 @@ def plot(self, *args, scalex=True, scaley=True, **kwargs): | ||
You may suppress the warning by adding an empty format string | ||
`plot('n', 'o', '', data=obj)`. | ||
Other Parameters | ||
---------------- | ||
scalex, scaley : bool, optional, default: True | ||
@@ -1512,13 +1469,11 @@ def plot(self, *args, scalex=True, scaley=True, **kwargs): | ||
lines | ||
A list of `.Line2D` objects representing the plotted data. | ||
See Also | ||
-------- | ||
scatter : XY scatter plot with markers of varying size and/or color ( | ||
sometimes also called bubble chart). | ||
Notes | ||
----- | ||
**Format Strings** | ||
@@ -1601,14 +1556,10 @@ def plot(self, *args, scalex=True, scaley=True, **kwargs): | ||
'k^:' # black triangle_up markers connected by a dotted line | ||
""" | ||
kwargs = cbook.normalize_kwargs(kwargs, mlines.Line2D._alias_map) | ||
lines = [*self._get_lines(*args, data=data, **kwargs)] | ||
for line inlines: | ||
self.add_line(line) | ||
self.autoscale_view(scalex=scalex, scaley=scaley) | ||
return lines | ||
@@ -1991,8 +1942,8 @@ def xcorr(self, x, y, normed=True, detrend=mlab.detrend_none, | ||
#### Specialized plotting | ||
#@_preprocess_data() # let 'plot' do the unpacking.. | ||
def step(self, x, y, *args, where='pre',data=None,**kwargs): | ||
""" | ||
Make a step plot. | ||
@@ -2057,17 +2008,9 @@ def step(self, x, y, *args, where='pre', **kwargs): | ||
raise ValueError("'where' argument to step must be " | ||
"'pre', 'post' or 'mid'") | ||
kwargs['drawstyle'] = 'steps-' + where | ||
return self.plot(x, y, *args, data=data, **kwargs) | ||
@_preprocess_data() | ||
@docstring.dedent_interpd | ||
def bar(self, x, height, width=0.8, bottom=None, *, align="center", | ||
**kwargs): | ||
@@ -2459,7 +2402,7 @@ def barh(self, y, width, height=0.8, left=None, *, align="center", | ||
align=align, **kwargs) | ||
return patches | ||
@_preprocess_data() | ||
@docstring.dedent_interpd | ||
def broken_barh(self, xranges, yrange, **kwargs): | ||
""" | ||
@@ -2530,9 +2473,9 @@ def broken_barh(self, xranges, yrange, **kwargs): | ||
return col | ||
@_preprocess_data() | ||
def stem(self, *args, linefmt=None, markerfmt=None, basefmt=None, bottom=0, | ||
label=None): | ||
""" | ||
Create a stem plot. | ||
@@ -2690,8 +2633,7 @@ def stem(self, *args, linefmt=None, markerfmt=None, basefmt=None, | ||
return stem_container | ||
@_preprocess_data(replace_names=["x", "explode", "labels", "colors"]) | ||
def pie(self, x, explode=None, labels=None, colors=None, | ||
autopct=None, pctdistance=0.6, shadow=False, labeldistance=1.1, | ||
startangle=None, radius=None, counterclock=True, | ||
@@ -3306,7 +3248,7 @@ def extract_err(err, data): | ||
return errorbar_container # (l0, caplines, barcols) | ||
@_preprocess_data() | ||
def boxplot(self, x, notch=None, sym=None, vert=None, whis=None, | ||
positions=None, widths=None, patch_artist=None, | ||
bootstrap=None, usermedians=None, conf_intervals=None, | ||
@@ -4835,7 +4777,7 @@ def _quiver_units(self, args, kw): | ||
return args | ||
# args can by a combination if X, Y, U, V, C and all should be replaced | ||
@_preprocess_data() | ||
def quiver(self, *args, **kw): | ||
# Make sure units are handled for x and y values | ||
args = self._quiver_units(args, kw) | ||
@@ -4848,13 +4790,12 @@ def quiver(self, *args, **kw): | ||
quiver.__doc__ = mquiver.Quiver.quiver_doc | ||
# args can by either Y or y1,y2,... and all should be replaced | ||
@_preprocess_data() | ||
def stackplot(self, x, *args, **kwargs): | ||
return mstack.stackplot(self, x, *args, **kwargs) | ||
stackplot.__doc__ = mstack.stackplot.__doc__ | ||
@_preprocess_data(replace_names=["x", "y", "u", "v", "start_points"]) | ||
def streamplot(self, x, y, u, v, density=1, linewidth=None, color=None, | ||
cmap=None, norm=None, arrowsize=1, arrowstyle='-|>', | ||
minlength=0.1, transform=None, zorder=None, | ||
@@ -4879,7 +4820,7 @@ def streamplot(self, x, y, u, v, density=1, linewidth=None, color=None, | ||
streamplot.__doc__ = mstream.streamplot.__doc__ | ||
# args can be some combination of X, Y, U, V, C and all should be replaced | ||
@_preprocess_data() | ||
@docstring.dedent_interpd | ||
def barbs(self, *args, **kw): | ||
""" | ||
@@ -4893,9 +4834,9 @@ def barbs(self, *args, **kw): | ||
self.autoscale_view() | ||
return b | ||
# Uses a custom implementation of data-kwarg handling in | ||
# _process_plot_var_args. | ||
def fill(self, *args,data=None,**kwargs): | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others.Learn more.
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others.Learn more. done | ||
""" | ||
Plot filled polygons. | ||
@@ -4918,6 +4859,13 @@ def fill(self, *args, **kwargs): | ||
ax.fill(x, y, x2, y2) # two polygons | ||
ax.fill(x, y, "b", x2, y2, "r") # a blue and a red polygon | ||
data : indexable object, optional | ||
An object with labelled data. If given, provide the label names to | ||
plot in *x* and *y*, e.g.:: | ||
ax.fill("time", "signal", | ||
data={"time": [0, 1, 2], "signal": [0, 1, 0]}) | ||
Returns | ||
------- | ||
a list of :class:`~matplotlib.patches.Polygon` | ||
@@ -4935,14 +4883,13 @@ def fill(self, *args, **kwargs): | ||
kwargs = cbook.normalize_kwargs(kwargs, mlines.Line2D._alias_map) | ||
patches = [] | ||
for poly in self._get_patches_for_fill(*args,data=data,**kwargs): | ||
self.add_patch(poly) | ||
patches.append(poly) | ||
self.autoscale_view() | ||
return patches | ||
@_preprocess_data(replace_names=["x", "y1", "y2", "where"]) | ||
@docstring.dedent_interpd | ||
def fill_between(self, x, y1, y2=0, where=None, interpolate=False, | ||
step=None, **kwargs): | ||
@@ -5124,8 +5071,7 @@ def get_interp_point(ind): | ||
self.autoscale_view() | ||
return collection | ||
@_preprocess_data(replace_names=["y", "x1", "x2", "where"]) | ||
@docstring.dedent_interpd | ||
def fill_betweenx(self, y, x1, x2=0, where=None, | ||
step=None, interpolate=False, **kwargs): | ||
@@ -5307,7 +5253,7 @@ def get_interp_point(ind): | ||
return collection | ||
#### plotting z(x,y): imshow, pcolor and relatives, contour | ||
@_preprocess_data() | ||
def imshow(self, X, cmap=None, norm=None, aspect=None, | ||
interpolation=None, alpha=None, vmin=None, vmax=None, | ||
origin=None, extent=None, shape=None, filternorm=1, | ||
@@ -5574,7 +5520,7 @@ def _pcolorargs(funcname, *args, allmatch=False): | ||
C = cbook.safe_masked_invalid(C) | ||
return X, Y, C | ||
@_preprocess_data() | ||
@docstring.dedent_interpd | ||
def pcolor(self, *args, alpha=None, norm=None, cmap=None, vmin=None, | ||
vmax=None, **kwargs): | ||
@@ -5811,7 +5757,7 @@ def pcolor(self, *args, alpha=None, norm=None, cmap=None, vmin=None, | ||
self.autoscale_view() | ||
return collection | ||
@_preprocess_data() | ||
@docstring.dedent_interpd | ||
def pcolormesh(self, *args, alpha=None, norm=None, cmap=None, vmin=None, | ||
vmax=None, shading='flat', antialiased=False, **kwargs): | ||
@@ -6024,7 +5970,7 @@ def pcolormesh(self, *args, alpha=None, norm=None, cmap=None, vmin=None, | ||
self.autoscale_view() | ||
return collection | ||
@_preprocess_data() | ||
@docstring.dedent_interpd | ||
def pcolorfast(self, *args, alpha=None, norm=None, cmap=None, vmin=None, | ||
vmax=None, **kwargs): | ||
@@ -6788,7 +6734,7 @@ def hist(self, x, bins=None, range=None, density=None, weights=None, | ||
else: | ||
return tops, bins, cbook.silent_list('Lists of Patches', patches) | ||
@_preprocess_data(replace_names=["x", "y", "weights"]) | ||
def hist2d(self, x, y, bins=10, range=None, normed=False, weights=None, | ||
cmin=None, cmax=None, **kwargs): | ||
""" | ||
@@ -6896,7 +6842,7 @@ def hist2d(self, x, y, bins=10, range=None, normed=False, weights=None, | ||
return h, xedges, yedges, pc | ||
@_preprocess_data(replace_names=["x"]) | ||
@docstring.dedent_interpd | ||
def psd(self, x, NFFT=None, Fs=None, Fc=None, detrend=None, | ||
window=None, noverlap=None, pad_to=None, | ||
@@ -7131,7 +7077,7 @@ def csd(self, x, y, NFFT=None, Fs=None, Fc=None, detrend=None, | ||
else: | ||
return pxy, freqs, line | ||
@_preprocess_data(replace_names=["x"]) | ||
@docstring.dedent_interpd | ||
def magnitude_spectrum(self, x, Fs=None, Fc=None, window=None, | ||
pad_to=None, sides=None, scale=None, | ||
@@ -7234,7 +7180,7 @@ def magnitude_spectrum(self, x, Fs=None, Fc=None, window=None, | ||
return spec, freqs, lines[0] | ||
@_preprocess_data(replace_names=["x"]) | ||
@docstring.dedent_interpd | ||
def angle_spectrum(self, x, Fs=None, Fc=None, window=None, | ||
pad_to=None, sides=None, **kwargs): | ||
@@ -7316,7 +7262,7 @@ def angle_spectrum(self, x, Fs=None, Fc=None, window=None, | ||
return spec, freqs, lines[0] | ||
@_preprocess_data(replace_names=["x"]) | ||
@docstring.dedent_interpd | ||
def phase_spectrum(self, x, Fs=None, Fc=None, window=None, | ||
pad_to=None, sides=None, **kwargs): | ||
@@ -7397,7 +7343,7 @@ def phase_spectrum(self, x, Fs=None, Fc=None, window=None, | ||
return spec, freqs, lines[0] | ||
@_preprocess_data(replace_names=["x", "y"]) | ||
@docstring.dedent_interpd | ||
def cohere(self, x, y, NFFT=256, Fs=2, Fc=0, detrend=mlab.detrend_none, | ||
window=mlab.window_hanning, noverlap=0, pad_to=None, | ||
@@ -7462,7 +7408,7 @@ def cohere(self, x, y, NFFT=256, Fs=2, Fc=0, detrend=mlab.detrend_none, | ||
return cxy, freqs | ||
@_preprocess_data(replace_names=["x"]) | ||
@docstring.dedent_interpd | ||
def specgram(self, x, NFFT=None, Fs=None, Fc=None, detrend=None, | ||
window=None, noverlap=None, | ||
@@ -7814,7 +7760,7 @@ def matshow(self, Z, **kwargs): | ||
integer=True)) | ||
return im | ||
@_preprocess_data(replace_names=["dataset"]) | ||
def violinplot(self, dataset, positions=None, vert=True, widths=0.5, | ||
showmeans=False, showextrema=True, showmedians=False, | ||
points=100, bw_method=None): | ||
Uh oh!
There was an error while loading.Please reload this page.