Struct implot::Plot [−][src]
pub struct Plot { /* fields omitted */ }
Expand description
Struct to represent an ImPlot. This is the main construct used to contain all kinds of plots in ImPlot.
Plot
is to be used (within an imgui window) with the following pattern:
let plotting_context = implot::Context::create();
let plot_ui = plotting_context.get_plot_ui();
implot::Plot::new("my title")
.size([300.0, 200.0]) // other things such as .x_label("some_label") can be added too
.build(&plot_ui, || {
// Do things such as plotting lines
});
(If you are coming from the C++ implementation or the C bindings: build() calls both begin() and end() internally)
Implementations
Create a new plot with some defaults set. Does not draw anything yet. Note that this uses antialiasing by default, unlike the C++ API. If you are seeing artifacts or weird rendering, try disabling it.
Sets the plot size, given as [size_x, size_y]. Units are the same as what imgui uses. TODO(4bb4) … which is? I’m not sure it’s pixels
Set the x limits of the plot.
Note: This conflicts with linked_x_limits
, whichever is called last on plot construction
takes effect.
Set linked x limits for this plot. Pass clones of the same Rc
into other plots
to link their limits with the same values.
Note: This conflicts with x_limits
, whichever is called last on plot construction takes
effect.
pub fn y_limits<L: Into<ImPlotRange>>(
self,
limits: L,
y_axis_choice: YAxisChoice,
condition: Condition
) -> Self
pub fn y_limits<L: Into<ImPlotRange>>(
self,
limits: L,
y_axis_choice: YAxisChoice,
condition: Condition
) -> Self
Set the Y limits of the plot for the given Y axis. Call multiple times with different
y_axis_choice
values to set for multiple axes, or use the convenience methods such as
Plot::y1_limits
.
Note: This conflicts with linked_y_limits
, whichever is called last on plot construction
takes effect for a given axis.
Convenience function to directly set the Y limits for the first Y axis. To programmatically
(or on demand) decide which axis to set limits for, use Plot::y_limits
Convenience function to directly set the Y limits for the second Y axis. To
programmatically (or on demand) decide which axis to set limits for, use Plot::y_limits
Convenience function to directly set the Y limits for the third Y axis. To programmatically
(or on demand) decide which axis to set limits for, use Plot::y_limits
pub fn linked_y_limits(
self,
limits: Rc<RefCell<ImPlotRange>>,
y_axis_choice: YAxisChoice
) -> Self
pub fn linked_y_limits(
self,
limits: Rc<RefCell<ImPlotRange>>,
y_axis_choice: YAxisChoice
) -> Self
Set linked Y limits of the plot for the given Y axis. Pass clones of the same Rc
into
other plots to link their limits with the same values. Call multiple times with different
y_axis_choice
values to set for multiple axes, or use the convenience methods such as
Plot::y1_limits
.
Note: This conflicts with y_limits
, whichever is called last on plot construction takes
effect for a given axis.
Convenience function to directly set linked Y limits for the first Y axis. To
programmatically (or on demand) decide which axis to set limits for, use
Plot::linked_y_limits
.
Convenience function to directly set linked Y limits for the second Y axis. To
programmatically (or on demand) decide which axis to set limits for, use
Plot::linked_y_limits
.
Convenience function to directly set linked Y limits for the third Y axis. To
programmatically (or on demand) decide which axis to set limits for, use
Plot::linked_y_limits
.
Set X ticks without labels for the plot. The vector contains one label each in
the form of a tuple (label_position, label_string)
. The show_default
setting
determines whether the default ticks are also shown.
Set X ticks without labels for the plot. The vector contains one label each in
the form of a tuple (label_position, label_string)
. The show_default
setting
determines whether the default ticks are also shown.
Set X ticks with labels for the plot. The vector contains one position and label
each in the form of a tuple (label_position, label_string)
. The show_default
setting determines whether the default ticks are also shown.
pub fn y_ticks_with_labels(
self,
y_axis_choice: YAxisChoice,
tick_labels: &[(f64, String)],
show_default: bool
) -> Self
pub fn y_ticks_with_labels(
self,
y_axis_choice: YAxisChoice,
tick_labels: &[(f64, String)],
show_default: bool
) -> Self
Set Y ticks with labels for the plot. The vector contains one position and label
each in the form of a tuple (label_position, label_string)
. The show_default
setting determines whether the default ticks are also shown.
Set the plot flags, see the help for PlotFlags
for what the available flags are
Set the axis flags for the X axis in this plot
Set the axis flags for the selected Y axis in this plot
pub fn with_legend_location(
self,
location: &PlotLocation,
orientation: &PlotOrientation,
outside: bool
) -> Self
pub fn with_legend_location(
self,
location: &PlotLocation,
orientation: &PlotOrientation,
outside: bool
) -> Self
Set the legend location, orientation and whether it is to be drawn outside the plot
Attempt to show the plot. If this returns a token, the plot will actually
be drawn. In this case, use the drawing functionality to draw things on the
plot, and then call end()
on the token when done with the plot.
If none was returned, that means the plot is not rendered.
For a convenient implementation of all this, use build()
instead.