Crate implot[][src]

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. Documentation copied from implot.h for convenience. ImPlot itself also has Lock, which combines LOCK_MIN and LOCK_MAX, and NoDecorations, which combines NO_GRID_LINES, NO_TICK_MARKS and NO_TICK_LABELS.

An implot context.

Struct to represent an ImPlot. This is the main construct used to contain all kinds of plots in ImPlot.

Struct to provide bar plotting functionality.

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 and NO_MOUSE_POSITION.

Struct to provide functionality for creating headmaps.

Struct to provide functionality for plotting a line in a plot.

Struct to provide functionality for creating a scatter plot

Struct to provide functionality for plotting a line in a plot with stairs style.

Struct to provide stem plotting functionality.

Struct to provide functionality for adding text within a plot

Tracks a plot that must be ended by calling .end()

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.

Tracks a change pushed to the style color stack

Tracks a change pushed to the style variable stack

Enums

Colormap choice. Documentation copied from implot.h for convenience.

Condition for applying a setting

Markers, documentation copied from implot.h for convenience.

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”.

Used to position items on a plot (e.g. legends, labels, etc.)

Used to orient items on a plot (e.g. legends, labels, etc.)

Style variable choice, as in “which thing will be affected by a style setting”.

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

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.

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.

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.

Returns true if the given item in the legend of the current plot is hovered.

Returns true if the plot area in the current or most recent plot is hovered.

Returns true if the current or most recent plot is queried

Returns true if the XAxis plot area in the current plot is 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.

Convert pixels, given as floats x and y, to a position in the current plot’s coordinate system. Uses the specified Y axis, if any, otherwise whatever was previously chosen.

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.

Convert a position in the current plot’s coordinate system to pixels. Uses the specified Y axis, if any, otherwise whatever was previously chosen.

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 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 a f32 style variable to the stack. The returned token is used for removing the variable from the stack again:

Push an u32 style variable to the stack. The only i32 style variable is Marker at the moment, for that, use something like

Push an ImVec2 style variable to the stack. The returned token is used for removing the variable from the stack again.

Switch to one of the built-in preset colormaps. If samples is greater than 1, the map will be linearly resampled.

Set a custom colormap in the form of a vector of colors.

Set the Y axis to be used for any upcoming plot elements

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.