FILE: docs/api/seaborn.md¶
Seaborn API Reference¶
Functions for exploratory data analysis: correlation heatmaps, distribution plots, and theme setup.
plot_corr(df, method='pearson', threshold=None, figsize='auto', cmap='coolwarm', annot=True, fmt='.2f', show=True, save=None, dpi=150)¶
Plot a correlation heatmap with a triangular mask.
Parameters:
- df – pandas DataFrame (numeric columns only)
- method – 'pearson', 'spearman', or 'kendall'
- threshold – if not None, highlight pairs with |corr| >= threshold and print list
- figsize – tuple or 'auto' (max(8, n_cols*0.8), max(6, n_cols*0.7))
- cmap – colormap for the heatmap
- annot – show correlation values in cells
- fmt – number format for annotations
- show – call plt.show()
- save – file path to save figure
- dpi – resolution for saved figure
Returns: matplotlib Axes
Example:
dk.plot_corr(df)
dk.plot_corr(df, method='spearman', threshold=0.5, figsize=(10, 8))
plot_distributions(df, cols=None, kde=True, include_boxplot=True, n_cols=2, figsize='auto', show=True, save_dir=None, dpi=150)¶
Plot histogram + boxplot for each numeric column.
Parameters:
- df – pandas DataFrame
- cols – list of column names (None = all numeric columns)
- kde – overlay kernel density estimate on histogram
- include_boxplot – show boxplot alongside histogram
- n_cols – number of panels per row (histogram + boxplot count as separate)
- figsize – tuple or 'auto' (default (12, 4) per row)
- show – call plt.show() after each figure
- save_dir – directory to save individual figures (None = don't save)
- dpi – resolution for saved figures
Returns: list of figure objects (one per column)
Example:
dk.plot_distributions(df)
dk.plot_distributions(df, cols=['age', 'income'], kde=False)
dk.plot_distributions(df, save_dir='figures/', show=False)
set_theme(style='whitegrid', palette='muted', font_scale=1.2, dpi=120, from_config=False, config_path='.datakit.toml')¶
Set up seaborn and matplotlib theme in one call.
Parameters:
- style – seaborn style ('whitegrid', 'darkgrid', 'white', 'dark', 'ticks')
- palette – seaborn colour palette
- font_scale – multiplier for font sizes
- dpi – figure DPI for matplotlib
- from_config – load settings from .datakit.toml and override parameters
- config_path – path to config file (used if from_config=True)
Returns: None
Example:
dk.set_theme()
dk.set_theme(style='darkgrid', palette='colorblind', font_scale=1.5)
dk.set_theme(from_config=True)