Movatterモバイル変換


[0]ホーム

URL:


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

Sign up
Appearance settings

Commit1eb540a

Browse files
committed
Cleanup and document _plot_args()
1 parent4e4410d commit1eb540a

File tree

1 file changed

+47
-9
lines changed

1 file changed

+47
-9
lines changed

‎lib/matplotlib/axes/_base.py

Lines changed: 47 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -403,12 +403,50 @@ def _makefill(self, x, y, kw, kwargs):
403403
returnseg,kwargs
404404

405405
def_plot_args(self,tup,kwargs,return_kwargs=False):
406+
"""
407+
Process the arguments of ``plot([x], y, [fmt], **kwargs)`` calls.
408+
409+
This processes a single set of ([x], y, [fmt]) parameters; i.e. for
410+
``plot(x, y, x2, y2)`` it will be called twice. Once for (x, y) and
411+
once for (x2, y2).
412+
413+
x and y may be 2D and thus can still represent multiple datasets.
414+
415+
For multiple datasets, if the keyword argument *label* is a list, this
416+
will unpack the list and assign the individual labels to the datasets.
417+
418+
Parameters
419+
----------
420+
tup : tuple
421+
A tuple of the positional parameters. This can be one of
422+
423+
- (y,)
424+
- (x, y)
425+
- (y, fmt)
426+
- (x, y, fmt)
427+
428+
kwargs : dict
429+
The keyword arguments passed to ``plot()``.
430+
431+
return_kwargs : bool
432+
If true, return the effective keyword arguments after label
433+
unpacking.
434+
435+
Returns
436+
-------
437+
result
438+
If *return_kwargs* is false, a list of Artists representing the
439+
dataset(s).
440+
If *return_kwargs* is true, a list of (Artist, effective_kwargs)
441+
representing the dataset(s). See *return_kwargs*.
442+
"""
406443
iflen(tup)>1andisinstance(tup[-1],str):
407-
linestyle,marker,color=_process_plot_format(tup[-1])
408-
tup=tup[:-1]
444+
*xy,fmt=tup
445+
linestyle,marker,color=_process_plot_format(fmt)
409446
eliflen(tup)==3:
410447
raiseValueError('third arg must be a format string')
411448
else:
449+
xy=tup
412450
linestyle,marker,color=None,None,None
413451

414452
# Don't allow any None value; these would be up-converted to one
@@ -417,16 +455,16 @@ def _plot_args(self, tup, kwargs, return_kwargs=False):
417455
raiseValueError("x, y, and format string must not be None")
418456

419457
kw= {}
420-
fork,vinzip(('linestyle','marker','color'),
421-
(linestyle,marker,color)):
458+
forprop_name,vinzip(('linestyle','marker','color'),
459+
(linestyle,marker,color)):
422460
ifvisnotNone:
423-
kw[k]=v
461+
kw[prop_name]=v
424462

425-
iflen(tup)==2:
426-
x=_check_1d(tup[0])
427-
y=_check_1d(tup[-1])
463+
iflen(xy)==2:
464+
x=_check_1d(xy[0])
465+
y=_check_1d(xy[1])
428466
else:
429-
x,y=index_of(tup[-1])
467+
x,y=index_of(xy[-1])
430468

431469
ifself.axes.xaxisisnotNone:
432470
self.axes.xaxis.update_units(x)

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp