Expand description
§Rust bindings to ImPlot
This crate contains idiomatic bindings to the C++ implot library,
which use the bindings exposed by the implot-sys
crate. An attempt is made to keep
documentation here somewhat self-contained, but when in doubt, the documentation of implot
itself (in particular also the demo code here)
should help as well.
For usage examples, see the implot-examples
crate - it contains standalone runnable examples
that showcase the API and features of this crate. The Github readme
lists the features that are already implemented as idiomatic bindings. For everything else, if
you’d really like a particular feature, file an issue and it’ll be given priority for wrapping,
or directly contribute a PR, or use the low-level bindings directly for the time being.
If you’ve seen a construct or feature in C++ implot and can’t find it here, try searching for the C++ name - some doc aliases are defined to increase the chances of that working. If this does not yield any results, you can also try cloning the source and doing a full-text search to see if the feature is used somewhere internally the code.
Structs§
- Axis
Flags - Axis flags. Documentation copied from implot.h for convenience. ImPlot itself also
has
Lock
, which combinesLOCK_MIN
andLOCK_MAX
, andNoDecorations
, which combinesNO_GRID_LINES
,NO_TICK_MARKS
andNO_TICK_LABELS
. - Context
- An implot context.
- ImPlot
Limits - ImPlot
Point - ImPlot
Range - ImVec2
- ImVec4
- Plot
- Struct to represent an ImPlot. This is the main construct used to contain all kinds of plots in ImPlot.
- Plot
Bars - Struct to provide bar plotting functionality.
- Plot
Flags - Flags for customizing plot behavior and interaction. Documentation copied from implot.h for
convenience. ImPlot itself also has a “CanvasOnly” flag, which can be emulated here with
the combination of
NO_LEGEND
,NO_MENUS
,NO_BOX_SELECT
andNO_MOUSE_POSITION
. - Plot
Heatmap - Struct to provide functionality for creating headmaps.
- Plot
Line - Struct to provide functionality for plotting a line in a plot.
- Plot
Scatter - Struct to provide functionality for creating a scatter plot
- Plot
Stairs - Struct to provide functionality for plotting a line in a plot with stairs style.
- Plot
Stems - Struct to provide stem plotting functionality.
- Plot
Text - Struct to provide functionality for adding text within a plot
- Plot
Token - Tracks a plot that must be ended by calling
.end()
- PlotUi
- A temporary reference for building plots. This does not really do anything on its own at this point, but it is used to enforce that a context is created and active for other features, such as creating plots.
- Style
Color Token - Tracks a change pushed to the style color stack
- Style
VarToken - Tracks a change pushed to the style variable stack
Enums§
- Colormap
- Colormap choice. Documentation copied from implot.h for convenience.
- Condition
- Condition for applying a setting
- Marker
- Markers, documentation copied from implot.h for convenience.
- Plot
Color Element - Colorable plot elements. These are called “ImPlotCol” in ImPlot itself, but I found that name somewhat confusing because we are not referring to colors, but which thing can be colored - hence I added the “Element”.
- Plot
Location - Used to position items on a plot (e.g. legends, labels, etc.)
- Plot
Orientation - Used to orient items on a plot (e.g. legends, labels, etc.)
- Style
Var - Style variable choice, as in “which thing will be affected by a style setting”.
- YAxis
Choice - Choice of Y axis. This an enum instead of just an integer so as to make it impossible
to select a Y axis that is not present - this makes it easier to avoid
Result
-type return values on functions that could otherwise not really fail.
Functions§
- get_
plot_ limits - Returns the current or most recent plot axis range for the specified choice of Y axis. If
None
is the Y axis choice, that means the most recently selected Y axis is chosen. - get_
plot_ mouse_ position - Returns the mouse position in x,y coordinates of the current or most recent plot,
for the specified choice of Y axis. If
None
is the Y axis choice, that means the most recently selected Y axis is chosen. - get_
plot_ query - Returns the query limits of the current or most recent plot, for the specified choice of Y
axis. If
None
is the Y axis choice, that means the most recently selected Y axis is chosen. - is_
legend_ entry_ hovered - Returns true if the given item in the legend of the current plot is hovered.
- is_
plot_ hovered - Returns true if the plot area in the current or most recent plot is hovered.
- is_
plot_ queried - Returns true if the current or most recent plot is queried
- is_
plot_ x_ axis_ hovered - Returns true if the XAxis plot area in the current plot is hovered.
- is_
plot_ y_ axis_ hovered - Returns true if the Y axis area of the given Y axis choice in the current plot is hovered. If
None
is the Y axis choice, that means the most recently selected Y axis is chosen. - pixels_
to_ plot_ f32 - Convert pixels, given as floats
x
andy
, to a position in the current plot’s coordinate system. Uses the specified Y axis, if any, otherwise whatever was previously chosen. - pixels_
to_ plot_ vec2 - Convert pixels, given as an
ImVec2
, to a position in the current plot’s coordinate system. Uses the specified Y axis, if any, otherwise whatever was previously chosen. - plot_
to_ pixels_ f32 - Convert a position in the current plot’s coordinate system to pixels. Uses the specified Y axis, if any, otherwise whatever was previously chosen.
- plot_
to_ pixels_ vec2 - Convert a position in the current plot’s coordinate system to pixels. Uses the specified Y axis, if any, otherwise whatever was previously chosen.
- push_
style_ color - Push a style color to the stack, giving an element and the four components of the color. The components should be between 0.0 (no intensity) and 1.0 (full intensity). The return value is a token that gets used for removing the style color from the stack again:
- push_
style_ var_ f32 - Push a f32 style variable to the stack. The returned token is used for removing the variable from the stack again:
- push_
style_ var_ i32 - Push an u32 style variable to the stack. The only i32 style variable is Marker at the moment, for that, use something like
- push_
style_ var_ imvec2 - Push an ImVec2 style variable to the stack. The returned token is used for removing the variable from the stack again.
- set_
colormap_ from_ preset - Switch to one of the built-in preset colormaps. If samples is greater than 1, the map will be linearly resampled.
- set_
colormap_ from_ vec - Set a custom colormap in the form of a vector of colors.
- set_
plot_ y_ axis - Set the Y axis to be used for any upcoming plot elements
- show_
demo_ window - Show the demo window for poking around what functionality implot has to offer. Note that not all of this is necessarily implemented in implot-rs already - if you find something missing you’d really like, raise an issue.