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 paletteand 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.apply_preset(name: str) None[source]
Make
namethe process-wide default for figures created from now on.
- upxo.viz.plot_quality.quality_context(name: str)[source]
Apply
nameinside 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 insidequality_context()); None if none has been applied.