topostats.plotting#
Plotting and summary of TopoStats output statistics.
Attributes#
Classes#
Class for summarising grain statistics in plots. |
Functions#
|
Process plotting and summarisation of data. |
|
Run Plotting |
Module Contents#
- topostats.plotting.LOGGER#
- class topostats.plotting.TopoSum(df: pandas.DataFrame = None, base_dir: str | pathlib.Path = None, csv_file: str | pathlib.Path = None, stat_to_sum: str = None, molecule_id: str = 'molecule_number', image_id: str = 'image', hist: bool = True, stat: str = 'count', bins: int = 12, kde: bool = True, cut: float = 20, figsize: tuple = (16, 9), alpha: float = 0.5, palette: str = 'deep', file_ext: str = 'png', output_dir: str | pathlib.Path = '.', var_to_label: dict = None, hue: str = 'basename')#
Class for summarising grain statistics in plots.
- df = None#
- base_dir = None#
- stat_to_sum = None#
- molecule_id = 'molecule_number'#
- image_id = 'image'#
- hist = True#
- bins = 12#
- stat = 'count'#
- kde = True#
- cut = 20#
- figsize = (16, 9)#
- alpha = 0.5#
- palette = 'deep'#
- file_ext = 'png'#
- output_dir#
- var_to_label = None#
- hue = 'basename'#
- melted_data = None#
- summary_data = None#
- label = None#
- _setup_figure()#
Setup Matplotlib figure and axes.
- _outfile(plot_suffix: str) str #
Generate the output file name with the appropriate suffix.
- Parameters:
plot_suffix (str) – The suffix to append to the output file.
- Returns:
Concanenated string of the outfile and plot_suffix.
- Return type:
str
- sns_plot() None #
Plot the distribution of one or more statistics as either histogram, kernel density estimates or both. Uses base Seaborn.
- sns_violinplot() None #
Violin plot of data.
- static melt_data(df: pandas.DataFrame, stat_to_summarize: str, var_to_label: dict) pandas.DataFrame #
Melt a dataframe into long format for plotting with Seaborn.
- set_xlim(percent: float = 0.1) None #
Set the range of the x-axis.
- Parameters:
percent (float) – Percentage of the observed range by which to extend the x-axis. Only used if supplied range is outside the
values. (observed)
- set_palette()#
Set the color palette.
- save_plot(outfile: pathlib.Path) None #
Save the plot to the output_dir
- Parameters:
outfile (str) – Output file name to save figure to.
- _set_label(var: str)#
Get the label based on the column name(s).
- Parameters:
var (str) – The variable for which a label is required.
- topostats.plotting.toposum(config: dict) Dict #
Process plotting and summarisation of data.
- Parameters:
config (dict) – Dictionary of summarisation options.
- Returns:
- Dictionary of nested dictionaries. Each variable has its own dictionary with keys ‘dist’ and ‘violin’ which
contain distribution like plots and violin plots respectively (if the later are required). Each ‘dist’ and
’violin’ is itself a dictionary with two elements ‘figures’ and ‘axes’ which correspond to MatplotLib ‘fig’ and ‘ax’ for that plot.
- Return type:
Dict
- topostats.plotting.run_toposum(args=None)#
Run Plotting