macrosynergy.panel.view_ranges#

Module for plotting ranges of values across cross-sections for one or more categories.

view_ranges(df, xcats, cids=None, start='2000-01-01', end=None, val='value', kind='bar', sort_cids_by=None, title=None, ylab=None, size=(16, 8), xcat_labels=None, legend_loc=None, legend_bbox_to_anchor=None)[source]#

Plots averages and various ranges across sections for one or more categories.

Parameters:
  • df (DataFrame) – standardized DataFrame with the necessary columns: ‘cid’, ‘xcat’, ‘real_date’ and at least one column with values of interest.

  • xcats (List[str]) – extended categories to be checked on. Default is all in the DataFrame.

  • cids (Optional[List[str]]) – cross sections to plot. Default is all in DataFrame.

  • start (str) – earliest date in ISO format. Default earliest date in df.

  • end (Optional[str]) – latest date in ISO format. Default is latest date in df.

  • val (str) – name of column that contains the values. Default is ‘value’.

  • kind (str) – type of range plot. Default is ‘bar’; other option is ‘box’.

  • sort_cids_by (Optional[str]) – criterion for sorting cids on x-axis; Arguments can be ‘mean’ and ‘std’. Default is None, i.e. original order. Ordering will be based on the first category if the category is defined over the complete panel. Otherwise, mean and standard deviation calculated, of the cross-sections, computed across all categories.

  • title (Optional[str]) – string of chart title; defaults depend on type of range plot.

  • ylab (Optional[str]) – y label. Default is no label.

  • size (Tuple[float]) – Tuple of width and height of graph. Default is (16, 8).

  • xcat_labels (Optional[List[str]]) – custom labels to be used for the ranges.

  • legend_loc (str) – location of legend; passed to matplotlib.pyplot.legend(). Default is ‘upper center’.

  • legend_bbox_to_anchor (Tuple[float]) – passed to matplotlib.pyplot.legend(). Default is (0.5, -0.15).