twaml.viz¶
The viz
module provides visualization tools.
twaml.viz
A module to aid visualizing our datasets
-
twaml.viz.
compare_columns
(ds1, ds2, columns=None, names=None, colors=None, density=True, **subplots_kw)[source]¶ generate a set of histograms comparing the distributions of a set of columns in two different datasets.
Parameters: - ds1 (twaml.data.dataset) – The first dataset
- ds2 (twaml.data.dataset) – The second dataset
- columns (Optional[List[str]]) – Columns to plot; if None, plot all
- names (Optional[Tuple[str,str]]) – Names for the legend, if None use the dataset
name
attributes - colors (Optional[Tuple[str,str]]) – Colors for the histograms
- density (bool) – Feed to
density
parameter inmatplotlib.pyplot.hist
- subplots_kw (Dict) – all additional keywords to send to
matplotlib.pyplot.subplots
-
twaml.viz.
compare_distributions
(dist1, dist2, bins=None, titles=['dist1', 'dist2'], colors=['C0', 'C1'], ratio=True, weight1=None, weight2=None, **subplots_kw)[source]¶ Compare two histogrammed distributons with matplotlib
Parameters: - dist1 – any mpl-histogrammable object (
np.ndarray
,pd.Series
, etc.) - dist2 – any mpl-histogrammable object (
np.ndarray
,pd.Series
, etc.) - bins (np.ndarray) – define the bin edges
- titles (List[str]) – labels for the distributions
- ratio (bool) – add a ratio plot
- weight1 (Optional[np.ndarray]) – weights associated with dist1
- weight2 (Optional[np.ndarray]) – weights associated with dist2
- subplots_kw (Dict) – all additional keywords to send to
matplotlib.pyplot.subplots
Returns: - fig (matpotlib.figure.Figure)
- ax (matplotlib.axes.Axes or array of them) – ax can be either a single matplotlib.axes.Axes object or an array of Axes objects if more than one subplot was created. The dimensions of the resulting array can be controlled with the squeeze keyword, see above.
- h1 – the return of
matplotlib.axes.Axes.hist
for dist1 - h2 – the return of
matplotlib.axes.Axes.hist
for dist2
- dist1 – any mpl-histogrammable object (