mgplot.revision_plot
revision_plot.py
Plot ABS revisions to estimates over time. This is largely a wrapper around the line_plot function, with some default settings and minimal checks on the data.
1""" 2revision_plot.py 3 4Plot ABS revisions to estimates over time. This is largely 5a wrapper around the line_plot function, with some 6default settings and minimal checks on the data. 7""" 8 9# --- imports 10from typing import Unpack 11from matplotlib.pyplot import Axes 12from pandas import DataFrame 13 14from mgplot.utilities import check_clean_timeseries 15from mgplot.line_plot import LineKwargs, line_plot 16from mgplot.keyword_checking import validate_kwargs, report_kwargs 17from mgplot.settings import DataT 18 19 20# --- constants 21ME = "revision_plot" 22 23 24# --- functions 25def revision_plot(data: DataT, **kwargs: Unpack[LineKwargs]) -> Axes: 26 """ 27 Plot the revisions to ABS data. 28 29 Arguments 30 data: pd.DataFrame - the data to plot, the DataFrame has a 31 column for each data revision 32 kwargs - additional keyword arguments for the line_plot function. 33 """ 34 35 # --- check the kwargs and data 36 report_kwargs(caller=ME, **kwargs) 37 validate_kwargs(schema=LineKwargs, caller=ME, **kwargs) 38 data = check_clean_timeseries(data, ME) 39 40 # --- additional checks 41 if not isinstance(data, DataFrame): 42 print(f"{ME}() requires a DataFrame with columns for each revision, not a Series or any other type.") 43 44 # --- critical defaults 45 kwargs["plot_from"] = kwargs.get("plot_from", -15) 46 kwargs["annotate"] = kwargs.get("annotate", True) 47 kwargs["annotate_color"] = kwargs.get("annotate_color", "black") 48 kwargs["rounding"] = kwargs.get("rounding", 3) 49 50 # --- plot 51 axes = line_plot(data, **kwargs) 52 53 return axes
ME =
'revision_plot'
def
revision_plot( data: ~DataT, **kwargs: Unpack[mgplot.LineKwargs]) -> matplotlib.axes._axes.Axes:
26def revision_plot(data: DataT, **kwargs: Unpack[LineKwargs]) -> Axes: 27 """ 28 Plot the revisions to ABS data. 29 30 Arguments 31 data: pd.DataFrame - the data to plot, the DataFrame has a 32 column for each data revision 33 kwargs - additional keyword arguments for the line_plot function. 34 """ 35 36 # --- check the kwargs and data 37 report_kwargs(caller=ME, **kwargs) 38 validate_kwargs(schema=LineKwargs, caller=ME, **kwargs) 39 data = check_clean_timeseries(data, ME) 40 41 # --- additional checks 42 if not isinstance(data, DataFrame): 43 print(f"{ME}() requires a DataFrame with columns for each revision, not a Series or any other type.") 44 45 # --- critical defaults 46 kwargs["plot_from"] = kwargs.get("plot_from", -15) 47 kwargs["annotate"] = kwargs.get("annotate", True) 48 kwargs["annotate_color"] = kwargs.get("annotate_color", "black") 49 kwargs["rounding"] = kwargs.get("rounding", 3) 50 51 # --- plot 52 axes = line_plot(data, **kwargs) 53 54 return axes
Plot the revisions to ABS data.
Arguments data: pd.DataFrame - the data to plot, the DataFrame has a column for each data revision kwargs - additional keyword arguments for the line_plot function.