PcolorPlot

Overview

class omdi::PcolorPlot : public omdi::Plot, public omdi::plots::DataPlot<omdi::GridXY>

Class for creating 2D heatmap (pseudocolor) plots.

The omdi::PcolorPlot class renders 2D scalar fields (e.g. omdi::GridXY) as pseudocolor heatmaps using ImPlot. It supports:

  • GPU-accelerated heatmap rendering for interactive performance,

  • an accompanying colorbar to visualize data ranges,

  • configurable aspect ratio (equal or free),

  • per-series visual customization via ImPlotSpec,

  • selection of colormap via ImPlotColormap.

Multiple named datasets can be registered; the active dataset is selected via an internal index. Datasets are stored by value inside the inherited omdi::plots::DataPlot<omdi::GridXY> base, so no external data lifetime management is required.

Usage example

Basic usage with a single grid:

// Create pcolor plot with just a label — no data yet
auto pcolor = omdi::PcolorPlot { "Scalar Field" };

// Add or replace all datasets at once
pcolor.update_all({
  { "field", omdi::GridXY { xs, ys, nx, ny, zs } }
});

// Or construct with initial data directly:
auto pcolor2 = omdi::PcolorPlot { "Scalar Field", {
  { "field", omdi::GridXY { xs, ys, nx, ny, zs } }
}};

// Inside your ImGui/ImPlot drawing code:
pcolor.plot();

Data members

bool omdi::PcolorPlot::m_aspect_equal

Flag controlling whether the plot uses an equal aspect ratio.

When true, the X and Y axes are scaled so that units are equal on both axes, preserving the geometric shape of the grid.

int omdi::PcolorPlot::m_which

Index of the currently selected dataset in the internal data map.

This determines which grid is displayed when omdi::PcolorPlot::plot() is called.

ImPlotColormap omdi::PcolorPlot::m_colormap

Colormap used for the pseudocolor rendering.

Defaults to ImPlotColormap_Viridis. Other ImPlot colormaps can be selected to change the visual appearance of the heatmap and colorbar.

Constructor

omdi::PcolorPlot::PcolorPlot(const std::string &label = "PcolorPlot", const std::map<std::string, omdi::GridXY> &data = {}, bool aspect_equal = true)

Construct a pseudocolor plot with an optional label and initial datasets.

Parameters:
  • label – Plot label / title (used in ImPlot). Defaults to "PcolorPlot".

  • data – Map from dataset names to omdi::GridXY values. Data is copied into the plot on construction. Defaults to an empty map.

  • aspect_equal – Whether to enforce equal aspect ratio for the axes (defaults to true).

Inherited from DataPlot<GridXY>

The following methods are inherited from omdi::plots::DataPlot<omdi::GridXY> and can be called directly on a omdi::PcolorPlot instance.

void omdi::PcolorPlot::update(const std::string &label, omdi::GridXY data)

Replace or insert a single named grid dataset.

Parameters:
  • label – Name of the dataset to update.

  • data – New omdi::GridXY value (copied by value).

void omdi::PcolorPlot::update_all(std::map<std::string, omdi::GridXY> new_data)

Replace all datasets at once.

Parameters:

new_data – Map of new datasets. Replaces the entire contents of the internal data store.

auto omdi::PcolorPlot::set_spec(const std::string &label, const ImPlotSpec &spec) -> void

Set the per-series plot specification for a named dataset.

Parameters:
  • label – Dataset label to associate the spec with.

  • specImPlotSpec controlling the visual appearance of the series.

auto omdi::PcolorPlot::get_spec(const std::string &label) const -> ImPlotSpec

Get the per-series plot specification for a named dataset.

Parameters:

label – Dataset label whose spec to retrieve.

Returns:

The ImPlotSpec associated with label.

Plotting

void omdi::PcolorPlot::plot() override

Render the pseudocolor plot.

This method overrides omdi::Plot::plot() and:

It is typically called inside an ImGui/ImPlot context, for example within a window where plotting is performed.

Notes