MCPcopy
hub / github.com/matplotlib/matplotlib / __call__

Method __call__

lib/matplotlib/axes/_base.py:261–334  ·  view source on GitHub ↗
(self, axes, *args, data=None, return_kwargs=False, **kwargs)

Source from the content-addressed store, hash-verified

259 self._prop_cycle = _PropCycle(mpl._val_or_rc(cycler, 'axes.prop_cycle'))
260
261 def __call__(self, axes, *args, data=None, return_kwargs=False, **kwargs):
262 axes._process_unit_info(kwargs=kwargs)
263
264 for pos_only in "xy":
265 if pos_only in kwargs:
266 raise _api.kwarg_error(inspect.stack()[1].function, pos_only)
267
268 if not args:
269 return
270
271 if data is None: # Process dict views
272 args = [cbook.sanitize_sequence(a) for a in args]
273 else: # Process the 'data' kwarg.
274 replaced = [mpl._replacer(data, arg) for arg in args]
275 if len(args) == 1:
276 label_namer_idx = 0
277 elif len(args) == 2: # Can be x, y or y, c.
278 # Figure out what the second argument is.
279 # 1) If the second argument cannot be a format shorthand, the
280 # second argument is the label_namer.
281 # 2) Otherwise (it could have been a format shorthand),
282 # a) if we did perform a substitution, emit a warning, and
283 # use it as label_namer.
284 # b) otherwise, it is indeed a format shorthand; use the
285 # first argument as label_namer.
286 try:
287 _process_plot_format(args[1])
288 except ValueError: # case 1)
289 label_namer_idx = 1
290 else:
291 if replaced[1] is not args[1]: # case 2a)
292 _api.warn_external(
293 f"Second argument {args[1]!r} is ambiguous: could "
294 f"be a format string but is in 'data'; using as "
295 f"data. If it was intended as data, set the "
296 f"format string to an empty string to suppress "
297 f"this warning. If it was intended as a format "
298 f"string, explicitly pass the x-values as well. "
299 f"Alternatively, rename the entry in 'data'.",
300 RuntimeWarning)
301 label_namer_idx = 1
302 else: # case 2b)
303 label_namer_idx = 0
304 elif len(args) == 3:
305 label_namer_idx = 1
306 else:
307 raise ValueError(
308 "Using arbitrary long args with data is not supported due "
309 "to ambiguity of arguments; use multiple plotting calls "
310 "instead")
311 if kwargs.get("label") is None:
312 kwargs["label"] = mpl._label_from_arg(
313 replaced[label_namer_idx], args[label_namer_idx])
314 args = replaced
315 ambiguous_fmt_datakey = data is not None and len(args) == 2
316
317 if len(args) >= 4 and not cbook.is_scalar_or_string(
318 kwargs.get("label")):

Callers

nothing calls this directly

Calls 4

_plot_argsMethod · 0.95
_process_plot_formatFunction · 0.85
_process_unit_infoMethod · 0.80
getMethod · 0.45

Tested by

no test coverage detected