Config Module#
The cleopatra.config module provides a small, opt-in helper for selecting the
matplotlib backend. Importing cleopatra does not change the backend on its own —
picking a backend is the application's job, not a library's.
Call Config.set_matplotlib_backend() yourself if you want cleopatra to choose a sensible
one for you: %matplotlib inline inside a Jupyter notebook (or %matplotlib notebook
when interactive=True), otherwise Agg in a plain script. You can also pass an explicit
backend name. set_matplotlib_backend is a staticmethod, so Config.set_matplotlib_backend(...)
works without an instance. Note that switching the backend closes any open figures — that
is matplotlib's behaviour — so call it before you start plotting.
from cleopatra.config import Config
Config.set_matplotlib_backend("Agg") # explicit
Config.set_matplotlib_backend() # auto: inline in notebooks, Agg otherwise
Module Documentation#
cleopatra.config
#
Matplotlib backend helpers for cleopatra.
Importing cleopatra does not change the active matplotlib backend —
picking a backend is the application's responsibility, not a library's.
Use Config.set_matplotlib_backend if you want a one-liner that selects
a sensible backend (%matplotlib inline in a Jupyter notebook, Agg in
a plain script).
Config
#
Configuration helpers for the cleopatra package.
Source code in src/cleopatra/config.py
set_matplotlib_backend(backend=None, interactive=False)
staticmethod
#
Switch the active matplotlib backend (opt-in helper).
cleopatra does not call this automatically. It is provided for users who want a one-liner to pick a backend. Switching the backend closes every currently-open figure — that is matplotlib's behaviour, not cleopatra's — so call this before you start plotting.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
backend
|
str | None
|
Backend name to switch to (e.g. |
None
|
interactive
|
bool
|
When |
False
|
Returns:
| Name | Type | Description |
|---|---|---|
str |
str
|
The name of the backend that is now active. |
Source code in src/cleopatra/config.py
is_notebook()
#
Return True if the code is running in a Jupyter notebook / qtconsole.