Plot Configuration
scikit-explain provides a seaborn-style configuration API that lets you set plotting defaults once and have them apply to all subsequent plot calls. This avoids passing display_feature_names, display_units, and other options to every method.
The key methods are:
explainer.set_plotting_config(**kwargs)— set defaultsexplainer.get_plotting_config()— inspect current configexplainer.reset_plotting_config()— restore defaults
[ ]:
import skexplain
import plotting_config
[ ]:
estimators = skexplain.load_models()
X, y = skexplain.load_data()
explainer = skexplain.ExplainToolkit(estimators=estimators, X=X, y=y)
Setting Plot Configuration
Call set_plotting_config() once after creating the ExplainToolkit. All subsequent plot calls will use these settings as defaults.
[ ]:
explainer.set_plotting_config(
display_feature_names=plotting_config.display_feature_names,
display_units=plotting_config.display_units,
feature_colors=plotting_config.color_dict,
style='ticks',
base_font_size=12,
)
Now plot calls are clean — no need to pass display names or units every time:
[ ]:
ale = explainer.ale(features=['sfc_temp', 'temp2m', 'dwpt2m', 'sat_irbt'], n_bins=20)
explainer.plot_ale(ale=ale)
[ ]:
perm_imp = explainer.permutation_importance(n_vars=10, evaluation_fn='norm_aupdc')
explainer.plot_importance(
data=perm_imp,
panels=[('multipass', 'Random Forest')],
)
Per-Call Overrides
You can still pass arguments directly to any plot method. Per-call arguments always override the config defaults.
[ ]:
# Override display names for just this one plot
explainer.plot_ale(
ale=ale,
display_feature_names={'sfc_temp': 'Surface Temp (custom)'},
)
Inspecting Configuration
Use get_plotting_config() to see the current settings:
[ ]:
config = explainer.get_plotting_config()
print(config)
Changing the Seaborn Theme
The style, palette, font_scale, and rc options control the seaborn theme, similar to seaborn.set_theme().
[ ]:
explainer.set_plotting_config(
style='whitegrid',
base_font_size=16,
)
explainer.plot_ale(ale=ale)
Resetting to Defaults
Call reset_plotting_config() to clear all custom settings and return to the default matplotlib/seaborn appearance.
[ ]:
explainer.reset_plotting_config()
# Now plots use default feature names (no pretty labels)
explainer.plot_ale(ale=ale)
Available Configuration Options
Option |
Type |
Description |
|---|---|---|
|
dict |
Map feature names to display names |
|
dict |
Map feature names to unit strings |
|
dict |
Map feature names to colors |
|
tuple |
Default figure size (width, height) |
|
int |
Columns in multi-panel layouts |
|
float |
Subplot spacing |
|
int |
Base font size |
|
str |
Seaborn style (‘ticks’, ‘whitegrid’, etc.) |
|
str |
Seaborn color palette |
|
float |
Font scaling factor |
|
dict |
Matplotlib rcParams overrides |
|
bool |
Add histograms behind ALE/PD curves |
|
bool |
Display as percentages |
|
int |
Default number of features to plot |