upxo.viz.plot_quality module

Plot-quality presets: one switch for fonts, line widths, palette and DPI.

Three presets are provided:

  • "quick" small fonts, low DPI; for fast iteration.

  • "high" clean defaults for everyday inspection.

  • "publication" serif fonts, inward ticks, a colour-blind-safe palette

    and 300 DPI export; editable text in SVG/PDF.

Every preset defines the same set of matplotlib rcParams, so switching from one preset to another fully replaces the previous one.

matplotlib reads most rcParams when an artist is created, so a preset affects figures drawn after it is applied, not ones already drawn. Settings passed explicitly to a plotting call (fontsize=, dpi=, …) are unaffected and take precedence.

Use apply_preset to change the process-wide default, or quality_context to scope a preset to a block:

from upxo.viz import plot_quality
with plot_quality.quality_context("publication"):
    fig = make_the_figure()
    fig.savefig("fig1.pdf", dpi=plot_quality.savefig_dpi("publication"))
upxo.viz.plot_quality.preset_names() → List[str][source]

Names of the available presets, in order of increasing quality.

upxo.viz.plot_quality.get_preset(name: str) → Dict[source]

A copy of the rcParams dict of a preset.

upxo.viz.plot_quality.apply_preset(name: str) → None[source]

Make name the process-wide default for figures created from now on.

upxo.viz.plot_quality.quality_context(name: str)[source]

Apply name inside the block only; rcParams are restored on exit.

upxo.viz.plot_quality.current_preset() → str | None[source]

Name of the preset last applied with apply_preset() (or active inside quality_context()); None if none has been applied.

upxo.viz.plot_quality.savefig_dpi(name: str | None = None) → int[source]

DPI to use when saving a figure: that of name, else of the current preset, else of the default preset.

upxo.viz.plot_quality.describe(name: str) → str[source]

One-line description of a preset.