Skip to content

set_config

yohou.plotting._utils.set_config(*, resampler=None, resampler_n_shown_samples=None, resampler_downsampler=None, resampler_gap_handler=None, resampler_trace_prefix_suffix=None, resampler_show_mean_aggregation_size=None)

Set global plotting configuration.

Parameters

Name Type Description Default
resampler bool | Literal['widget'] | None

Controls plotly-resampler usage for time-axis plots.

  • False - plain go.Figure (default).
  • True - FigureResampler (Dash-based callback server).
  • "widget" - FigureWidgetResampler (notebook-native widget).
  • None - leave current value unchanged.
None
resampler_n_shown_samples int | None

Default number of samples shown per trace when resampling is active. None leaves current value unchanged (library default: 1000).

None
resampler_downsampler AbstractAggregator | None

Default downsampling algorithm (e.g. MinMaxLTTB(), LTTB()). None leaves current value unchanged (library default: MinMaxLTTB()).

None
resampler_gap_handler AbstractGapHandler | None

Default gap detection strategy (e.g. MedDiffGapHandler(), NoGapHandler()). None leaves current value unchanged (library default: MedDiffGapHandler()).

None
resampler_trace_prefix_suffix tuple[str, str] | None

Prefix and suffix added to legend names of resampled traces. None leaves current value unchanged (library default: ('[R] ', '')).

None
resampler_show_mean_aggregation_size bool | None

Whether to show the mean aggregation bin size as a legend suffix. None leaves current value unchanged (library default: True).

None

Examples

>>> from yohou.plotting import set_config, get_config
>>> set_config(resampler="widget")
>>> get_config()["resampler"]
'widget'
>>> set_config(resampler=False)

See Also

get_config : Read the current configuration. config_context : Temporarily override configuration.

Source Code

Show/Hide source
def set_config(
    *,
    resampler: bool | Literal["widget"] | None = None,
    resampler_n_shown_samples: int | None = None,
    resampler_downsampler: AbstractAggregator | None = None,
    resampler_gap_handler: AbstractGapHandler | None = None,
    resampler_trace_prefix_suffix: tuple[str, str] | None = None,
    resampler_show_mean_aggregation_size: bool | None = None,
) -> None:
    """Set global plotting configuration.

    Parameters
    ----------
    resampler : bool | Literal["widget"] | None, default=None
        Controls plotly-resampler usage for time-axis plots.

        - ``False`` - plain ``go.Figure`` (default).
        - ``True`` - ``FigureResampler`` (Dash-based callback server).
        - ``"widget"`` - ``FigureWidgetResampler`` (notebook-native widget).
        - ``None`` - leave current value unchanged.
    resampler_n_shown_samples : int | None, default=None
        Default number of samples shown per trace when resampling is active.
        ``None`` leaves current value unchanged (library default: 1000).
    resampler_downsampler : AbstractAggregator | None, default=None
        Default downsampling algorithm (e.g. ``MinMaxLTTB()``, ``LTTB()``).
        ``None`` leaves current value unchanged (library default: ``MinMaxLTTB()``).
    resampler_gap_handler : AbstractGapHandler | None, default=None
        Default gap detection strategy (e.g. ``MedDiffGapHandler()``, ``NoGapHandler()``).
        ``None`` leaves current value unchanged (library default: ``MedDiffGapHandler()``).
    resampler_trace_prefix_suffix : tuple[str, str] | None, default=None
        Prefix and suffix added to legend names of resampled traces.
        ``None`` leaves current value unchanged (library default: ``('[R] ', '')``).
    resampler_show_mean_aggregation_size : bool | None, default=None
        Whether to show the mean aggregation bin size as a legend suffix.
        ``None`` leaves current value unchanged (library default: ``True``).

    Examples
    --------
    >>> from yohou.plotting import set_config, get_config
    >>> set_config(resampler="widget")
    >>> get_config()["resampler"]
    'widget'
    >>> set_config(resampler=False)

    See Also
    --------
    [`get_config`][yohou.plotting.get_config] : Read the current configuration.
    [`config_context`][yohou.plotting.config_context] : Temporarily override configuration.
    """
    if resampler is not None:
        _global_config["resampler"] = resampler
    if resampler_n_shown_samples is not None:
        _global_config["resampler_n_shown_samples"] = resampler_n_shown_samples
    if resampler_downsampler is not None:
        _global_config["resampler_downsampler"] = resampler_downsampler
    if resampler_gap_handler is not None:
        _global_config["resampler_gap_handler"] = resampler_gap_handler
    if resampler_trace_prefix_suffix is not None:
        _global_config["resampler_trace_prefix_suffix"] = resampler_trace_prefix_suffix
    if resampler_show_mean_aggregation_size is not None:
        _global_config["resampler_show_mean_aggregation_size"] = resampler_show_mean_aggregation_size