spacepy.plot.set_target

spacepy.plot.set_target(target, figsize=None, loc=None, polar=False)[source]

Given a target on which to plot a figure, determine if that target is None or a matplotlib figure or axes object. Based on the type of target, a figure and/or axes will be either located or generated. Both the figure and axes objects are returned to the caller for further manipulation. This is used in nearly all add_plot-type methods.

Parameters
targetobject

The object on which plotting will happen.

Returns
figobject

A matplotlib figure object on which to plot.

axobject

A matplotlib subplot object on which to plot.

Other Parameters
figsizetuple

A two-item tuple/list giving the dimensions of the figure, in inches. Defaults to Matplotlib defaults.

locinteger

The subplot triple that specifies the location of the axes object. Defaults to matplotlib default (111).

polarbool

Set the axes object to polar coodinates. Defaults to False.

Examples

>>> import matplotlib.pyplot as plt
>>> from spacepy.pybats import set_target
>>> fig = plt.figure()
>>> fig, ax = set_target(target=fig, loc=211)