Cleopatra - Matplotlib utility package#
cleopatra is a Python package providing a fast and flexible way to build visualize data using matplotlib. It provides functionalities to handle 3D arrays and perform various operations on them, such as plotting, animating, and displaying the array. It also provides functionalities for creating statistical plots.
Package Layout#
graph TD
cleopatra["cleopatra"]
cleopatra --> glyph["glyph<br/>Glyph (base class)"]
cleopatra --> array_glyph["array_glyph<br/>ArrayGlyph, FacetGrid"]
cleopatra --> mesh_glyph["mesh_glyph<br/>MeshGlyph"]
cleopatra --> statistical_glyph["statistical_glyph<br/>StatisticalGlyph"]
cleopatra --> tiles["tiles<br/>add_tiles + helpers (optional 'tiles' extra)"]
cleopatra --> colors["colors<br/>Colors"]
cleopatra --> styles["styles<br/>Styles, Scale, ColorScale, MidpointNormalize"]
cleopatra --> config["config<br/>Config (matplotlib backend helper)"]
array_glyph -. extends .-> glyph
mesh_glyph -. extends .-> glyph
glyphprovides the sharedGlyphbase class (figure/axes lifecycle, colorbars, color norms, ticks, animation).array_glyph(ArrayGlyph,FacetGrid),mesh_glyph(MeshGlyph), andstatistical_glyph(StatisticalGlyph) are the user-facing visualizers;ArrayGlyphandMeshGlyphsubclassGlyph,StatisticalGlyphstands alone.tilesadds the optional web-tile basemap helper (cleopatra.tiles.add_tiles), behind thecleopatra[tiles]extra.colors,styles, andconfigare supporting utilities (colour conversions, predefined styles /MidpointNormalize/ColorScale, and the matplotlib-backend helper).
Main Features#
ArrayGlyph — raster / array visualization#
- Plot 2-D and 3-D
numpyarrays with automatic colorbars and selectable colour scales (linear,power,sym-lognorm,boundary-norm,midpoint), rendered viaimshow,pcolormesh,contour, orcontourf(plot(kind=...)). - xarray-aligned colour options:
robust,center,levels,extend,cbar_kwargs. - Curvilinear / non-uniform grids with
coords=(x, y); faceted grids of subplots withfacet(col=, row=, col_wrap=, extents=)→FacetGrid. - Animate 3-D arrays over time (with an optional lazy
data_getterfor streaming frames) and export to GIF / MP4 / MOV / AVI (via ffmpeg). - Overlay point markers and per-cell value labels.
See the ArrayGlyph reference.
MeshGlyph — unstructured mesh visualization#
- Visualise UGRID-style unstructured meshes with
tripcolor/tricontourfand wireframe outlines; animate time-varying mesh data.
See the MeshGlyph reference.
StatisticalGlyph — histograms#
- 1-D and 2-D histograms with customizable bins, colours, and transparency.
See the Statistical plots reference.
cleopatra.tiles — web-tile basemaps (optional)#
add_tiles(ax, ...)overlays an XYZ web-tile basemap (OpenStreetMap, CartoDB, Esri, …) underneath your data — pure Python, no GDAL. Behind thecleopatra[tiles]extra (conda install -c conda-forge cleopatra-tiles).
See the Tiles reference.
Colors, styles, config#
Colors— convert between hex / RGB(0–255) / normalized-RGB(0–1) and build colormaps from images.styles— predefined line/marker styles,ColorScale, andMidpointNormalize.config— an opt-in helper for picking the matplotlib backend (importingcleopatradoes not change it).