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 defaults

  • explainer.get_plotting_config() — inspect current config

  • explainer.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

display_feature_names

dict

Map feature names to display names

display_units

dict

Map feature names to unit strings

feature_colors

dict

Map feature names to colors

figsize

tuple

Default figure size (width, height)

n_columns

int

Columns in multi-panel layouts

wspace / hspace

float

Subplot spacing

base_font_size

int

Base font size

style

str

Seaborn style (‘ticks’, ‘whitegrid’, etc.)

palette

str

Seaborn color palette

font_scale

float

Font scaling factor

rc

dict

Matplotlib rcParams overrides

add_hist

bool

Add histograms behind ALE/PD curves

to_probability

bool

Display as percentages

num_vars_to_plot

int

Default number of features to plot