calamari.plot.draw_map#

calamari.plot.draw_map(grid, *, ax=None, family_scale='linear', show_samples=True, clim=None, robust_percentiles=(1.0, 99.0), transitions=None, transition_kwargs=None, **mesh_kwargs)#

Render a PlotGrid as a colour map on the T-H plane.

Orientation is always temperature on x and applied field (Tesla, mu0 H) on y – the conventional H-T phase diagram – whichever axis the sweeps ran along. Returns the QuadMesh, which is the handle a colourbar needs (fig.colorbar(mesh, ax=ax, label=grid.value_label)); figure-level concerns stay with the caller per PL-1, and the axes are reachable as mesh.axes.

Honesty defaults, each overridable:

  • NaN cells render in an explicit grey, never transparent – on a white background under a light-ended colormap a transparent hole is indistinguishable from a low value.

  • show_samples=True scatters the real sample positions over the mesh, so every gridding decision is visible on the figure itself.

  • Sparse family rows are capped at the median row spacing (see _family_edges()), leaving visible gaps rather than painting colour halfway to a distant sweep.

  • The axes title carries grid.value_label (and the selected frequency, when one was recorded), so the figure says what it shows without the caption’s help.

  • The colour range defaults to the data’s min and max, and warns when that range is wasted: if the central 95 % of cells occupy less than a quarter of it, a few extreme cells own the colourbar and the map renders nearly flat. The warning names the fix (clim=) rather than applying one, because clipping the range hides real values and that is the caller’s decision.

Parameters:
  • grid (PlotGrid) – From chi_map_grid() / moment_map_grid().

  • ax (Axes | None) – Draw into these axes, or omit to create a figure.

  • family_scale (str) – Spacing of the family axis (the one with a row per sweep). 'linear' is physically true and the default; 'log' suits log-spaced held fields (refused if any value is not positive – use 'index' for families that include zero field); 'index' gives every sweep an equal-height row with the true values as tick labels (the axis becomes categorical: distance on it means nothing).

  • show_samples (bool) – Overlay the real sample positions. Default True.

  • clim (optional) – Colour limits. None (default): the finite cells’ min and max, with the flat-map warning above. 'minmax': the same limits, no warning – you have looked and want the full range. 'robust': the robust_percentiles of the finite cells (MAP_ROBUST_PERCENTILES, 1-99 by default), which unseats a handful of extreme cells; cells outside the limits saturate, so tell the colourbar (fig.colorbar(..., extend='both')). (vmin, vmax): explicit limits. Passing vmin/vmax in mesh_kwargs is the same as an explicit pair and is refused alongside a non-default clim.

  • robust_percentiles (tuple[float, float]) – The lower and upper percentiles clim='robust' uses.

  • transitions (optional) – Transition candidates (a TransitionResult, or its candidates table) to overlay after drawing – forwarded to overlay_transitions() with this grid and family_scale, so the overlay cannot be lied to about how the map was rendered.

  • transition_kwargs (dict | None) – Extra keyword arguments for overlay_transitions().

  • **mesh_kwargs (Any) – Forwarded to ax.pcolormesh (cmap=, vmin=, …); shading='flat' with explicit edges is used and cannot be overridden. rasterized=True is the default: in a vector file the mesh is embedded as a single image at savefig.dpi (600 under a journal style) while axes, text and the sample overlay stay vector. A vector mesh is thousands of adjacent filled paths, and PDF viewers antialias their shared edges into a visible hairline lattice; rasterising is the standard cure. Pass rasterized=False for a fully vector file.