iode.Variables.plot

Variables.plot(names: str | List[str] = None, periods: str | List[str] = None, plot_type: str = 'line', title: str = None, xlabel: str = 'periods', ylabel: str = 'values', grid: str = 'major', y_log: bool = False, y_min: float = None, y_max: float = None, legend: bool = True, show: bool = True)[source]

Plot the variables defined by names for the periods defined by periods.

If names is a string, it is considered as a pattern and the function will plot all variables matching the pattern. The following characters in pattern have a special meaning:

  • * : any character sequence, even empty

  • ? : any character (one and only one)

  • @ : any alphanumerical char [A-Za-z0-9]

  • & : any non alphanumerical char

  • | : any alphanumeric character or none at the beginning and end of a string

  • ! : any non-alphanumeric character or none at the beginning and end of a string

  • `` : escape the next character

If names is None, plot all variables of the (subset of the) current database.

Parameters:
names: str or list of str, optional

pattern or list of names of the variables to plot. If None, plot all variables of the (subset of the) current database. Defaults to None.

periods: str or list of str, optional

pattern or list of periods to plot. If None, plot all periods of the (subset of the) current database. Defaults to None.

plot_type: str, optional

type of the plot. Possible values are ‘line’, ‘bar’, ‘scatter’. Defaults to ‘line’.

title: str, optional

title of the plot. Defaults to None.

xlabel: str, optional

label for x-axis. Defaults to ‘periods’.

ylabel: str, optional

label for y-axis. Defaults to ‘values’.

grid: str, optional

grid type to use. Possible values are ‘major’, ‘minor’ or ‘none’. Defaults to ‘major’.

y_log: bool, optional

whether to use logarithmic scale for y-axis. Defaults to False.

y_min: float, optional

minimum value for y-axis. If None, the minimum value is automatically determined.

y_max: float, optional

maximum value for y-axis. If None, the maximum value is automatically determined.

legend: bool, optional

whether to show legend. Defaults to True.

showbool, optional

If True, the plot will be displayed immediately. If False, the plot will not be shown until plt.show() is called. Default is True.

Returns:
ax: matplotlib.axes.Axes

The Axes object containing the plot.

Examples

>>> from iode import SAMPLE_DATA_DIR, variables
>>> variables.load(f"{SAMPLE_DATA_DIR}/fun.var")
Loading .../fun.var
394 objects loaded
>>> ax = variables.plot("ACAF;ACAG", "2000Y1;2010Y1", title="ACAF and ACAG variables")