tslumen.plot.interactive package

Interactive plots using ploly. Require extra dependencies to be installed.

tslumen.plot.interactive.comparison module

Comparison plots.

class tslumen.plot.interactive.comparison.Heatmap(data: pandas.core.frame.DataFrame, label_xaxis: str = '', label_yaxis: str = '', xrotation: int = 0, show_labels: bool = True, labels_format: str = '{:.2f}', cmap: Union[str, List[str]] = 'PuBu', colorbar: bool = True, colorbar_position: str = 'right', colorbar_limit: Tuple[float, float] = (- 1.0, 1.0), fmt_colorbar: str = '0.00 a', hovertemplate: str = '<b>%{meta.label_xaxis}</b>: %{x}<br><b>%{meta.label_yaxis}</b>: %{y}<br><b>Value</b>: %{z}<extra></extra>', title: str = '', width: Optional[int] = None, height: int = 400, **layout_opts: Any)[source]

Bases: tslumen.plot.interactive.base.VizBase

Heatmap plot.

Parameters
  • data (pd.DataFrame) – Matrix with the coefficient values.

  • label_xaxis (str) – X-axis label, default ‘’.

  • label_yaxis (str) – X-axis label, default ‘’.

  • xrotation (int) – Rotation degree to apply to the x axis, default 0.

  • show_labels (bool) – Whether to show the coefficient on the heatmap, default True.

  • labels_format (str) – Format to apply to the labels, default ‘{0:.2f}’.

  • cmap (str) – Color map or palette, default ‘PuBu’.

  • colorbar (bool) – Whether to show the color bar, default True.

  • colorbar_position (str) – Where to position the colorbar, e.g. ‘left’, ‘right’, etc.

  • colorbar_limit (Tuple[float, float]) – Min and max colorbar range, default (-1, 1).

class tslumen.plot.interactive.comparison.Radar(data: pandas.core.frame.DataFrame, columns: Optional[List[str]] = None, labels: Optional[List[str]] = None, colors: Optional[List[str]] = None, axis_range: Optional[tuple] = None, show_legend: bool = False, legend_position: str = 'bottom_left', fill: Optional[str] = 'toself', title: str = '', width: Optional[int] = None, height: int = 400, **layout_opts: Any)[source]

Bases: tslumen.plot.interactive.base.VizBase

Radar (aka spider) plot for comparing data bearing multiple dimensions.

Parameters
  • data (pd.DataFrame) – Dataframe to be plotted.

  • columns (list) – Subset of columns to use (optional).

  • labels (list) – Option to re-label the columns (defined positionally).

  • colors (list) – For coloring each of the series being plotted.

  • axis_range (Tuple[Number, Number]) – Manually define the range of values to plot.

  • show_legend (bool) – Switches legend on/off.

  • legend_position (str) – Controls the legend positioning.

tslumen.plot.interactive.correlation module

Correlation plots.

class tslumen.plot.interactive.correlation.LagCorrelation(data: pandas.core.frame.DataFrame, col_corr: Optional[str] = 'correlation', col_lag: Optional[str] = 'lag', col_up_bound: Optional[str] = 'up', col_lo_bound: Optional[str] = 'low', label_corr: Optional[str] = None, label_lag: Optional[str] = None, label_up_bound: Optional[str] = None, label_lo_bound: Optional[str] = None, label_xaxis: str = 'Lag', label_yaxis: str = 'Correlation', color_area: str = 'rgba(160, 158, 187, 0.25)', color_vlines: str = 'black', color_up_bound: str = '#a09ebb', color_lo_bound: str = '#a09ebb', color_circle: str = '#a09ebb', scatter_size: int = 6, vlines_width: float = 2, title: str = '', width: Optional[int] = None, height: int = 400, **layout_opts: Any)[source]

Bases: tslumen.plot.interactive.base.VizBase

Lag correlation (ACF/PACF) plots, commonly known as lollipop, for analysing correlation on a given lag. Useful for auto-, partial-, cross- and partial-cross-correlation.

Parameters
  • data (pd.DataFrame) – Dataframe with lag, correlation and optionally upper and lower CI.

  • col_corr (str) – Name of the correlation column.

  • col_lag (str) – Name of the lag column.

  • col_up_bound (str) – Name of the upper boundary column.

  • col_lo_bound (str) – Name of the lower boundary column.

  • label_corr (str) – Label for the correlation, defaults to col_corr if not provided.

  • label_lag (str) – Label for the lag, defaults to col_lag if not provided.

  • label_up_bound (str) – Label for the upper boundary, defaults to col_up_bound.

  • label_lo_bound (str) – Label for the upper boundary, defaults to col_lo_bound.

  • legend_position (str) – Where to position the legend, default ‘right’.

  • label_xaxis (str) – X-axis label, default ‘Lag’.

  • label_yaxis (str) – Y-axis label, default ‘Correlation’.

  • color_area (str) – Color of the shaded area between the boundaries.

  • color_vlines (str) – Color of the vertical lines/spikes.

  • color_up_bound (str) – Color of the upper boundary line.

  • color_lo_bound (str) – Color of the lower boundary line.

  • color_circle (str) – Color of the scatter points.

  • scatter_size (float) – Size of the scatter points, default 6.

  • vlines_width (float) – Width of the vertical lines/spikes, default 2.

class tslumen.plot.interactive.correlation.LagMatrix(data: pandas.core.frame.DataFrame, corr: Union[pandas.core.frame.DataFrame, dict], col_original: str = 'original', ncols: int = 2, show_legend: bool = False, xrotation: int = 0, hovertemplate: str = '<b>%{meta.label_xaxis}</b>: %{x}<br><b>%{meta.label_yaxis}</b>: %{y}<extra></extra>', title: str = '', width: Optional[int] = None, height: int = 400, **layout_opts: Any)[source]

Bases: tslumen.plot.interactive.base.VizBase

Lag Matrix plot.

class tslumen.plot.interactive.correlation.ScatterMatrix(data: pandas.core.frame.DataFrame, corr: pandas.core.frame.DataFrame, show_legend: bool = False, xrotation: int = 0, hovertemplate: str = '<b>%{meta.label_xaxis}</b>: %{x}<br><b>%{meta.label_yaxis}</b>: %{y}<extra></extra>', title: str = '', width: Optional[int] = None, height: int = 400, **layout_opts: Any)[source]

Bases: tslumen.plot.interactive.base.VizBase

Scatter matrix (aka pair plot) with scatters, KDE and correlation Heatmap.

tslumen.plot.interactive.distribution module

Distribution plots.

class tslumen.plot.interactive.distribution.BoxPlot(data: Union[pandas.core.frame.DataFrame, pandas.core.series.Series], labels: Optional[list] = None, label_xaxis: Optional[str] = '', label_yaxis: Optional[str] = '', xrotation: int = 0, show_legend: bool = False, legend_position: str = 'right', color: Optional[Union[str, list]] = None, hovertemplate: str = '<b>%{meta.label_xaxis}</b>: %{x}<br><b>%{meta.label_yaxis}</b>: %{y:d}<extra></extra>', title: str = '', width: Optional[int] = None, height: int = 400, **layout_opts: Any)[source]

Bases: tslumen.plot.interactive.base.VizBase

BoxPlot w/ whiskers.

class tslumen.plot.interactive.distribution.Histogram(data: Union[pandas.core.frame.DataFrame, pandas.core.series.Series], labels: Optional[list] = None, label_xaxis: Optional[str] = 'Bin', label_yaxis: Optional[str] = 'Count', xrotation: int = 0, show_legend: bool = False, legend_position: str = 'right', color: Optional[Union[str, list]] = None, bargap: Union[int, float] = 0.1, barmode: str = 'stack', hovertemplate: str = '<b>%{meta.label_xaxis}</b>: %{x}<br><b>%{meta.label_yaxis}</b>: %{y:d}<extra></extra>', title: str = '', width: Optional[int] = None, height: int = 400, **layout_opts: Any)[source]

Bases: tslumen.plot.interactive.base.VizBase

Histogram plot, displaying the distribution of continuous values.

Parameters
  • data (Union[pd.DataFrame, pd.Series]) – Values to be plotted on the histogram.

  • labels (list) – Optional labels.

  • label_xaxis (str) – X-axis label, default to ‘Bins’.

  • label_yaxis (str) – Y-axis label, default to ‘Count’.

  • xrotation (int) – Rotation degree to apply to the x axis, default 0.

  • show_legend (bool) – Whether to show the legend, default False.

  • legend_position (str) – Where to position the legend, default ‘right’.

  • color (Union[str, list]) – Color of the plot bars.

  • bargap (Union[float, int]) – Gap between each bar of the histogram, default 0.1.

  • barmode (str) – Options include “stack” (default), “relative”, “group” and “overlay”.

  • width (int) – The width of the plot.

  • height (int) – The height of the plot.

class tslumen.plot.interactive.distribution.SampleTheoretical(data: pandas.core.frame.DataFrame, col_theoretical: str, col_sample: str, col_reference: str, label_xaxis: Optional[str] = 'Theoretical', label_yaxis: Optional[str] = 'Sample', xrotation: int = 0, hovertemplate: str = '<b>%{meta.label_xaxis}</b>: %{x}<br><b>%{meta.label_yaxis}</b>: %{y}<extra></extra>', title: str = '', width: Optional[int] = None, height: int = 400, **layout_opts: Any)[source]

Bases: tslumen.plot.interactive.base.VizBase

PP/QQ plot.

tslumen.plot.interactive.line module

Line plots.

class tslumen.plot.interactive.line.TS(df: pandas.core.frame.DataFrame, columns: Optional[Union[str, list]] = None, labels: Optional[Union[str, list]] = None, colors: Optional[Union[str, list]] = None, line_width: Optional[Union[float, list]] = 1.5, label_xaxis: str = '', label_yaxis: str = '', fmt_x: str = '%b/%Y', fmt_y: str = '', xaxis: Optional[Union[bool, str]] = 'bottom', yaxis: Optional[Union[bool, str]] = 'left', show_legend: bool = True, legend_position: str = 'right', rangeslider: bool = True, rangeselector: bool = True, hovertemplate: str = '<b>%{meta.label_xaxis}</b>: %{x}<br><b>%{meta.label}</b>: %{y:.2f}<extra></extra>', title: str = '', width: Optional[int] = None, height: int = 400, **layout_opts: Any)[source]

Bases: tslumen.plot.interactive.base.VizBase

TimeSeries plot, displaying each column in the input dataframe as a curve over time.

class tslumen.plot.interactive.line.TSStack(df: pandas.core.frame.DataFrame, show_all_xaxis: bool = False, columns: Optional[Union[str, list]] = None, labels: Optional[Union[str, list]] = None, colors: Optional[Union[str, list]] = None, line_width: Optional[Union[float, list]] = 1.5, label_xaxis: str = '', label_yaxis: str = '', fmt_x: str = '%b/%Y', fmt_y: str = '', xaxis: Optional[Union[bool, str]] = 'bottom', yaxis: Optional[Union[bool, str]] = 'left', show_legend: bool = True, legend_position: str = 'right', rangeslider: bool = True, rangeselector: bool = True, hovertemplate: str = '<b>%{meta.label_xaxis}</b>: %{x}<br><b>%{meta.label}</b>: %{y:.2f}<extra></extra>', title: str = '', width: Optional[int] = None, height: int = 400, **layout_opts: Any)[source]

Bases: tslumen.plot.interactive.line.TS

TimeSeries Stacked plot for stacking a set of plots in one single vertical column. One trace per plot and all plots reading from the same date index.

tslumen.plot.interactive.misc module

Miscellaneous plots.

class tslumen.plot.interactive.misc.GrangerMatrix(data: pandas.core.frame.DataFrame, dfl: pandas.core.frame.DataFrame, critical: float = 0.05, cmap: str = 'PuBu_r', bg_reject: str = '#ffffff', fg_reject: str = '#dddddd', labels_format: str = '{:.5f}', hovertemplate: str = '<b>%{x} => %{y}</b>: %{z}<extra></extra>', xrotation: int = 0, label_xaxis: str = '', label_yaxis: str = '', show_labels: bool = True, colorbar: bool = True, colorbar_position: str = 'right', colorbar_limit: Tuple[float, float] = (- 1.0, 1.0), fmt_colorbar: str = '0.00 a', title: str = '', width: Optional[int] = None, height: int = 400, **layout_opts: Any)[source]

Bases: tslumen.plot.interactive.comparison.Heatmap

Granger causality matrix.

Args: data (pd.DataFrame): Matrix with the coefficient values. label_xaxis (str): X-axis label, default ‘’. label_yaxis (str): X-axis label, default ‘’. xrotation (int): Rotation degree to apply to the x axis, default 0. show_labels (bool): Whether to show the coefficient on the heatmap, default True. labels_format (str): Format to apply to the labels, default ‘{0:.2f}’. cmap (str): Color map or palette, default ‘PuBu’. colorbar (bool): Whether to show the color bar, default True. colorbar_position (str): Where to position the colorbar, e.g. ‘left’, ‘right’, etc. colorbar_limit (Tuple[float, float]): Min and max colorbar range, default (-1, 1).