Skip to main content

Apply the Haiqu matplotlib style

haiqu.sdk.set_haiqu_mpl_style(font_path=None)

Apply the Haiqu matplotlib style to the current session. When haiqu.sdk is imported inside a Jupyter environment this function is called automatically. Outside of Jupyter — for example in a script or a testing harness — call it explicitly after importing haiqu.sdk. The function makes the following changes to the active matplotlib session:
  • Colour cycle — sets the default series colours to the Haiqu brand palette (Morpho Blue, Orange, Red, Light Blue, Black, Neutral Grey).
  • Colormaps — registers two named colormaps:
    • haiqu_blue — sequential, white → Light Blue → Morpho Blue.
    • haiqu — diverging, Orange → white → Morpho Blue.
    haiqu is set as the default image colormap (image.cmap).
  • Typography — if available, registers and activates provided font as the monospace typeface used for tick labels, axis labels, and captions. Typically this should be the Suisse Int’l Mono font, if it is available. The font HAIQU_MPL_FONT_PATH environment variable or the font_path arg should provide the path.
  • Style — applies the bundled haiqu.mplstyle sheet (minimal axes, no top/right spines, dashed grid, square scatter markers, high-DPI save).
  • Parameters: font_path (str | None) — The path to the font. Defaults to None. If font_path is not specified, the HAIQU_MPL_FONT_PATH environment variable is checked. If it is not set, the matplotlib default font is used.
  • Return type: None

Examples

Automatic application inside a notebook (nothing extra required):
Explicit application in a script:
Using the registered colormaps directly:

Restore the default matplotlib style

haiqu.sdk.unset_haiqu_mpl_style()

Restore matplotlib to its default style, undoing set_haiqu_mpl_style(). Resets all rcParams to the matplotlib defaults (equivalent to calling matplotlib.rcdefaults()). The two brand colormaps (haiqu_blue and haiqu) remain available in the colormap registry and can still be referenced by name, but they are no longer the active defaults. Use this function when you need to produce a plot without the Haiqu style in the same session where haiqu.sdk was imported.

Examples

Temporarily disable the Haiqu style for a single plot:
Re-apply afterwards:
  • Return type: None