1.1. Boost v2 — the ImPlot DSL: snapshot plot scopes, OR-typed items, Setup*/SetNext* styling, drag tools, coordinate helpers
The v2 DSL for ImPlot. A chart is a plot
scope — plot(IDENT, (title, size, flags)) { ... } — that brackets
BeginPlot / EndPlot so the end call can’t be skipped, runs its body only
when the plot is visible, and serializes the plot’s per-frame state (screen
geometry, axis limits, hovered, mouse-plot-pos) into the dasImgui snapshot rail
under the plot’s container path. That snapshot hook is what makes a plot testable
from the playwright layer; the query
functions it reads (GetPlotPos / GetPlotLimits / IsPlotHovered / …) are
only valid between BeginPlot and EndPlot, so the capture happens eagerly
in-scope.
Items inside a scope are OR-typed over float | double | int — one
plot_line / plot_scatter / plot_bars / … call site regardless of the
element type — with paired xs / ys overloads for explicit x/y series.
Setup* wrappers configure axes and the legend; SetNext* wrappers style the
next item (auto-sentinel defaults mirror ImPlot’s “auto”). The interactive
drag tools (drag_point / drag_line_x / drag_line_y / drag_rect)
each own a persistent state struct the caller passes in: the bound value updates in
place as the handle is dragged, and serializes into the snapshot under
<plot>/<id> with the handle’s screen bbox (computed from its data position via
PlotToPixels) so a test can target and drag it.
1.1.1. Structures
- LegendEntry
struct LegendEntry
- PlotScopeState
struct PlotScopeState
- SubplotScopeState
struct SubplotScopeState
- DragPointState
struct DragPointState
- DragLineState
struct DragLineState
- DragRectState
struct DragRectState
1.1.2. Call macros
- plot
Function annotation plot
- subplots
Function annotation subplots
1.1.3. Axis & legend setup
- set_axes(x_axis: ImAxis; y_axis: ImAxis )
def set_axes (x_axis: ImAxis; y_axis: ImAxis)
- set_axis(axis: ImAxis )
def set_axis (axis: ImAxis)
- Arguments:
axis : ImAxis
- setup_axes(x_label: string; y_label: string; x_flags: ImPlotAxisFlags = implot::ImPlotAxisFlags.None; y_flags: ImPlotAxisFlags = implot::ImPlotAxisFlags.None )
def setup_axes (x_label: string; y_label: string; x_flags: ImPlotAxisFlags = implot::ImPlotAxisFlags.None; y_flags: ImPlotAxisFlags = implot::ImPlotAxisFlags.None)
- Arguments:
x_label : string
y_label : string
x_flags : ImPlotAxisFlags
y_flags : ImPlotAxisFlags
- setup_axes_limits(x_min: double; x_max: double; y_min: double; y_max: double; cond: ImPlotCond = implot::ImPlotCond.Once )
def setup_axes_limits (x_min: double; x_max: double; y_min: double; y_max: double; cond: ImPlotCond = implot::ImPlotCond.Once)
- Arguments:
x_min : double
x_max : double
y_min : double
y_max : double
cond : ImPlotCond
- setup_axis(axis: ImAxis; axis_label: string; flags: ImPlotAxisFlags = implot::ImPlotAxisFlags.None )
def setup_axis (axis: ImAxis; axis_label: string; flags: ImPlotAxisFlags = implot::ImPlotAxisFlags.None)
- Arguments:
axis : ImAxis
axis_label : string
flags : ImPlotAxisFlags
- setup_axis_limits(axis: ImAxis; v_min: double; v_max: double; cond: ImPlotCond = implot::ImPlotCond.Once )
def setup_axis_limits (axis: ImAxis; v_min: double; v_max: double; cond: ImPlotCond = implot::ImPlotCond.Once)
- Arguments:
axis : ImAxis
v_min : double
v_max : double
cond : ImPlotCond
- setup_legend(location: ImPlotLocation; flags: ImPlotLegendFlags = implot::ImPlotLegendFlags.None )
def setup_legend (location: ImPlotLocation; flags: ImPlotLegendFlags = implot::ImPlotLegendFlags.None)
- Arguments:
location : ImPlotLocation
flags : ImPlotLegendFlags
1.1.4. Next-item styling
- next_axes_limits(x_min: double; x_max: double; y_min: double; y_max: double; cond: ImPlotCond = implot::ImPlotCond.Once )
def next_axes_limits (x_min: double; x_max: double; y_min: double; y_max: double; cond: ImPlotCond = implot::ImPlotCond.Once)
- Arguments:
x_min : double
x_max : double
y_min : double
y_max : double
cond : ImPlotCond
- next_axes_to_fit()
def next_axes_to_fit ()
- next_fill_style(col: float4; alpha_mod: float = -1f )
def next_fill_style (col: float4; alpha_mod: float = -1f)
- Arguments:
col : float4
alpha_mod : float
- next_line_style(col: float4; weight: float = -1f )
def next_line_style (col: float4; weight: float = -1f)
- Arguments:
col : float4
weight : float
- next_marker_style(marker: ImPlotMarker; size: float = -1f; fill: float4 = float4(0f,0f,0f,-1f); weight: float = -1f; outline: float4 = float4(0f,0f,0f,-1f) )
def next_marker_style (marker: ImPlotMarker; size: float = -1f; fill: float4 = float4(0f,0f,0f,-1f); weight: float = -1f; outline: float4 = float4(0f,0f,0f,-1f))
- Arguments:
marker : ImPlotMarker
size : float
fill : float4
weight : float
outline : float4
1.1.5. Plot items
plot_digital (label_id: string; xs: array<auto(T)>; ys: array<T>; flags: int = 0) : auto
plot_dummy (label_id: string; flags: ImPlotDummyFlags = implot::ImPlotDummyFlags.None)
plot_line (label_id: string; xs: array<auto(T)>; ys: array<T>; flags: int = 0) : auto
plot_scatter (label_id: string; xs: array<auto(T)>; ys: array<T>; flags: int = 0) : auto
plot_stairs (label_id: string; xs: array<auto(T)>; ys: array<T>; flags: int = 0) : auto
- histogram(label_id: string; values: array<float>|array<double>|array<int>; bins: int = int(ImPlotBin.Sturges); bar_scale: double = 1lf; range_min: double = 0lf; range_max: double = 0lf; flags: int = 0 ): double
def histogram (label_id: string; values: array<float>|array<double>|array<int>; bins: int = int(ImPlotBin.Sturges); bar_scale: double = 1lf; range_min: double = 0lf; range_max: double = 0lf; flags: int = 0) : double
- Arguments:
label_id : string
values : option<array<float>| array<double>| array<int>>
bins : int
bar_scale : double
range_min : double
range_max : double
flags : int
- histogram2d(label_id: string; xs: array<auto(T)>; ys: array<T>; x_bins: int = int(ImPlotBin.Sturges); y_bins: int = int(ImPlotBin.Sturges); x_min: double = 0lf; x_max: double = 0lf; y_min: double = 0lf; y_max: double = 0lf; flags: int = 0 ): double
def histogram2d (label_id: string; xs: array<auto(T)>; ys: array<T>; x_bins: int = int(ImPlotBin.Sturges); y_bins: int = int(ImPlotBin.Sturges); x_min: double = 0lf; x_max: double = 0lf; y_min: double = 0lf; y_max: double = 0lf; flags: int = 0) : double
- Arguments:
label_id : string
xs : array<auto(T)>
ys : array<T>
x_bins : int
y_bins : int
x_min : double
x_max : double
y_min : double
y_max : double
flags : int
- plot_bar_groups(label_ids: array<string>; values: array<float>|array<double>|array<int>; item_count: int; group_count: int; group_size: double = 0.67lf; shift: double = 0lf; flags: int = 0 ): auto
def plot_bar_groups (label_ids: array<string>; values: array<float>|array<double>|array<int>; item_count: int; group_count: int; group_size: double = 0.67lf; shift: double = 0lf; flags: int = 0) : auto
- Arguments:
label_ids : array<string>
values : option<array<float>| array<double>| array<int>>
item_count : int
group_count : int
group_size : double
shift : double
flags : int
1.1.5.1. plot_bars
- plot_bars(label_id: string; values: array<float>|array<double>|array<int>; bar_size: double = 0.67lf; shift: double = 0lf; flags: int = 0 ): auto
def plot_bars (label_id: string; values: array<float>|array<double>|array<int>; bar_size: double = 0.67lf; shift: double = 0lf; flags: int = 0) : auto
- Arguments:
label_id : string
values : option<array<float>| array<double>| array<int>>
bar_size : double
shift : double
flags : int
- plot_bars(label_id: string; xs: array<auto(T)>; ys: array<T>; bar_size: double; flags: int = 0 ): auto
- plot_digital(label_id: string; xs: array<auto(T)>; ys: array<T>; flags: int = 0 ): auto
def plot_digital (label_id: string; xs: array<auto(T)>; ys: array<T>; flags: int = 0) : auto
- Arguments:
label_id : string
xs : array<auto(T)>
ys : array<T>
flags : int
- plot_dummy(label_id: string; flags: ImPlotDummyFlags = implot::ImPlotDummyFlags.None )
def plot_dummy (label_id: string; flags: ImPlotDummyFlags = implot::ImPlotDummyFlags.None)
- Arguments:
label_id : string
flags : ImPlotDummyFlags
1.1.5.2. plot_error_bars
- plot_error_bars(label_id: string; xs: array<auto(T)>; ys: array<T>; err: array<T>; flags: int = 0 ): auto
def plot_error_bars (label_id: string; xs: array<auto(T)>; ys: array<T>; err: array<T>; flags: int = 0) : auto
- Arguments:
label_id : string
xs : array<auto(T)>
ys : array<T>
err : array<T>
flags : int
- plot_error_bars(label_id: string; xs: array<auto(T)>; ys: array<T>; neg: array<T>; pos: array<T>; flags: int = 0 ): auto
- plot_heatmap(label_id: string; values: array<float>|array<double>|array<int>; rows: int; cols: int; scale_min: double = 0lf; scale_max: double = 0lf; label_fmt: string = "%.1f"; bounds_min: float2 = float2(0f,0f); bounds_max: float2 = float2(1f,1f); flags: int = 0 ): auto
def plot_heatmap (label_id: string; values: array<float>|array<double>|array<int>; rows: int; cols: int; scale_min: double = 0lf; scale_max: double = 0lf; label_fmt: string = “%.1f”; bounds_min: float2 = float2(0f,0f); bounds_max: float2 = float2(1f,1f); flags: int = 0) : auto
- Arguments:
label_id : string
values : option<array<float>| array<double>| array<int>>
rows : int
cols : int
scale_min : double
scale_max : double
label_fmt : string
bounds_min : float2
bounds_max : float2
flags : int
- plot_inf_lines(label_id: string; values: array<float>|array<double>|array<int>; flags: int = 0 ): auto
def plot_inf_lines (label_id: string; values: array<float>|array<double>|array<int>; flags: int = 0) : auto
- Arguments:
label_id : string
values : option<array<float>| array<double>| array<int>>
flags : int
1.1.5.3. plot_line
- plot_line(label_id: string; values: array<float>|array<double>|array<int>; xscale: double = 1lf; xstart: double = 0lf; flags: int = 0 ): auto
def plot_line (label_id: string; values: array<float>|array<double>|array<int>; xscale: double = 1lf; xstart: double = 0lf; flags: int = 0) : auto
- Arguments:
label_id : string
values : option<array<float>| array<double>| array<int>>
xscale : double
xstart : double
flags : int
- plot_line(label_id: string; xs: array<auto(T)>; ys: array<T>; flags: int = 0 ): auto
- plot_pie_chart(label_ids: array<string>; values: array<float>|array<double>|array<int>; x: double; y: double; radius: double; label_fmt: string = "%.1f"; angle0: double = 90lf; flags: int = 0 ): auto
def plot_pie_chart (label_ids: array<string>; values: array<float>|array<double>|array<int>; x: double; y: double; radius: double; label_fmt: string = “%.1f”; angle0: double = 90lf; flags: int = 0) : auto
- Arguments:
label_ids : array<string>
values : option<array<float>| array<double>| array<int>>
x : double
y : double
radius : double
label_fmt : string
angle0 : double
flags : int
1.1.5.4. plot_scatter
- plot_scatter(label_id: string; values: array<float>|array<double>|array<int>; xscale: double = 1lf; xstart: double = 0lf; flags: int = 0 ): auto
def plot_scatter (label_id: string; values: array<float>|array<double>|array<int>; xscale: double = 1lf; xstart: double = 0lf; flags: int = 0) : auto
- Arguments:
label_id : string
values : option<array<float>| array<double>| array<int>>
xscale : double
xstart : double
flags : int
- plot_scatter(label_id: string; xs: array<auto(T)>; ys: array<T>; flags: int = 0 ): auto
1.1.5.5. plot_shaded
- plot_shaded(label_id: string; values: array<float>|array<double>|array<int>; yref: double = 0lf; xscale: double = 1lf; xstart: double = 0lf; flags: int = 0 ): auto
def plot_shaded (label_id: string; values: array<float>|array<double>|array<int>; yref: double = 0lf; xscale: double = 1lf; xstart: double = 0lf; flags: int = 0) : auto
- Arguments:
label_id : string
values : option<array<float>| array<double>| array<int>>
yref : double
xscale : double
xstart : double
flags : int
- plot_shaded(label_id: string; xs: array<auto(T)>; ys: array<T>; yref: double = 0lf; flags: int = 0 ): auto
- plot_shaded_between(label_id: string; xs: array<auto(T)>; ys1: array<T>; ys2: array<T>; flags: int = 0 ): auto
def plot_shaded_between (label_id: string; xs: array<auto(T)>; ys1: array<T>; ys2: array<T>; flags: int = 0) : auto
- Arguments:
label_id : string
xs : array<auto(T)>
ys1 : array<T>
ys2 : array<T>
flags : int
1.1.5.6. plot_stairs
- plot_stairs(label_id: string; values: array<float>|array<double>|array<int>; xscale: double = 1lf; xstart: double = 0lf; flags: int = 0 ): auto
def plot_stairs (label_id: string; values: array<float>|array<double>|array<int>; xscale: double = 1lf; xstart: double = 0lf; flags: int = 0) : auto
- Arguments:
label_id : string
values : option<array<float>| array<double>| array<int>>
xscale : double
xstart : double
flags : int
- plot_stairs(label_id: string; xs: array<auto(T)>; ys: array<T>; flags: int = 0 ): auto
1.1.5.7. plot_stems
- plot_stems(label_id: string; values: array<float>|array<double>|array<int>; ref: double = 0lf; scale: double = 1lf; start: double = 0lf; flags: int = 0 ): auto
def plot_stems (label_id: string; values: array<float>|array<double>|array<int>; ref: double = 0lf; scale: double = 1lf; start: double = 0lf; flags: int = 0) : auto
- Arguments:
label_id : string
values : option<array<float>| array<double>| array<int>>
ref : double
scale : double
start : double
flags : int
- plot_stems(label_id: string; xs: array<auto(T)>; ys: array<T>; ref: double = 0lf; flags: int = 0 ): auto
- plot_text(text: string; x: double; y: double; pix_offset: float2 = float2(0f,0f); flags: ImPlotTextFlags = implot::ImPlotTextFlags.None )
def plot_text (text: string; x: double; y: double; pix_offset: float2 = float2(0f,0f); flags: ImPlotTextFlags = implot::ImPlotTextFlags.None)
- Arguments:
text : string
x : double
y : double
pix_offset : float2
flags : ImPlotTextFlags
1.1.6. Drag tools
- drag_line_x(state: DragLineState; id: string; col: float4; thickness: float = 1f; flags: ImPlotDragToolFlags = implot::ImPlotDragToolFlags.None )
def drag_line_x (var state: DragLineState; id: string; col: float4; thickness: float = 1f; flags: ImPlotDragToolFlags = implot::ImPlotDragToolFlags.None)
- Arguments:
state : DragLineState
id : string
col : float4
thickness : float
flags : ImPlotDragToolFlags
- drag_line_y(state: DragLineState; id: string; col: float4; thickness: float = 1f; flags: ImPlotDragToolFlags = implot::ImPlotDragToolFlags.None )
def drag_line_y (var state: DragLineState; id: string; col: float4; thickness: float = 1f; flags: ImPlotDragToolFlags = implot::ImPlotDragToolFlags.None)
- Arguments:
state : DragLineState
id : string
col : float4
thickness : float
flags : ImPlotDragToolFlags
- drag_point(state: DragPointState; id: string; col: float4; size: float = 4f; flags: ImPlotDragToolFlags = implot::ImPlotDragToolFlags.None )
def drag_point (var state: DragPointState; id: string; col: float4; size: float = 4f; flags: ImPlotDragToolFlags = implot::ImPlotDragToolFlags.None)
- Arguments:
state : DragPointState
id : string
col : float4
size : float
flags : ImPlotDragToolFlags
- drag_rect(state: DragRectState; id: string; col: float4; flags: ImPlotDragToolFlags = implot::ImPlotDragToolFlags.None )
def drag_rect (var state: DragRectState; id: string; col: float4; flags: ImPlotDragToolFlags = implot::ImPlotDragToolFlags.None)
- Arguments:
state : DragRectState
id : string
col : float4
flags : ImPlotDragToolFlags
1.1.7. Colormaps
- colormap_scale(label_id: string; scale_min: double; scale_max: double; cmap: ImPlotColormap; size: float2 = float2(0f,0f); fmt: string = "%g"; flags: ImPlotColormapScaleFlags = implot::ImPlotColormapScaleFlags.None )
def colormap_scale (label_id: string; scale_min: double; scale_max: double; cmap: ImPlotColormap; size: float2 = float2(0f,0f); fmt: string = “%g”; flags: ImPlotColormapScaleFlags = implot::ImPlotColormapScaleFlags.None)
- Arguments:
label_id : string
scale_min : double
scale_max : double
cmap : ImPlotColormap
size : float2
fmt : string
flags : ImPlotColormapScaleFlags
- pop_colormap(count: int = 1 )
def pop_colormap (count: int = 1)
- Arguments:
count : int
- push_colormap(cmap: ImPlotColormap )
def push_colormap (cmap: ImPlotColormap)
- Arguments:
cmap : ImPlotColormap
- sample_colormap(t: float; cmap: ImPlotColormap ): float4
def sample_colormap (t: float; cmap: ImPlotColormap) : float4
- Arguments:
t : float
cmap : ImPlotColormap
- with_colormap(cmap: ImPlotColormap; blk: block<():void> )
def with_colormap (cmap: ImPlotColormap; blk: block<():void>)
- Arguments:
cmap : ImPlotColormap
blk : block<void>
1.1.8. Coordinate conversion
- pixels_to_plot(px: float2; x_axis: ImAxis = implot::ImAxis.X1; y_axis: ImAxis = implot::ImAxis.Y1 ): ImPlotPoint
def pixels_to_plot (px: float2; x_axis: ImAxis = implot::ImAxis.X1; y_axis: ImAxis = implot::ImAxis.Y1) : ImPlotPoint
- plot_to_pixels(x: double; y: double; x_axis: ImAxis = implot::ImAxis.X1; y_axis: ImAxis = implot::ImAxis.Y1 ): float2
def plot_to_pixels (x: double; y: double; x_axis: ImAxis = implot::ImAxis.X1; y_axis: ImAxis = implot::ImAxis.Y1) : float2