pub struct PlotContext { /* private fields */ }Expand description
ImPlot context that manages the plotting state
This context is separate from the Dear ImGui context but works alongside it. You need both contexts to create plots.
Implementations§
Source§impl PlotContext
impl PlotContext
Sourcepub fn try_create(imgui_ctx: &ImGuiContext) -> ImGuiResult<Self>
pub fn try_create(imgui_ctx: &ImGuiContext) -> ImGuiResult<Self>
Try to create a new ImPlot context
This should be called after creating the Dear ImGui context. The ImPlot context will use the same Dear ImGui context internally.
Sourcepub fn create(imgui_ctx: &ImGuiContext) -> Self
pub fn create(imgui_ctx: &ImGuiContext) -> Self
Create a new ImPlot context (panics on error)
Sourcepub fn get_plot_ui<'ui>(&'ui self, ui: &'ui Ui) -> PlotUi<'ui>
pub fn get_plot_ui<'ui>(&'ui self, ui: &'ui Ui) -> PlotUi<'ui>
Get a PlotUi for creating plots
This borrows both the ImPlot context and the Dear ImGui Ui, ensuring that plots can only be created when both are available.
Sourcepub unsafe fn raw(&self) -> *mut ImPlotContext
pub unsafe fn raw(&self) -> *mut ImPlotContext
Get the raw ImPlot context pointer
§Safety
The caller must ensure the pointer is used safely and not stored beyond the lifetime of this context.
Source§impl PlotContext
impl PlotContext
Sourcepub fn add_colormap(
&self,
name: &str,
colors: &[[f32; 4]],
qualitative: bool,
) -> ColormapIndex
pub fn add_colormap( &self, name: &str, colors: &[[f32; 4]], qualitative: bool, ) -> ColormapIndex
Add a custom colormap from colors. The colors are copied by ImPlot.
Sourcepub fn colormap_count(&self) -> usize
pub fn colormap_count(&self) -> usize
Return the number of available colormaps.
Sourcepub fn colormap_name(&self, index: impl Into<ColormapIndex>) -> String
pub fn colormap_name(&self, index: impl Into<ColormapIndex>) -> String
Return a colormap name, or an empty string if the index is invalid for this context.
Sourcepub fn colormap_index_by_name(&self, name: &str) -> Option<ColormapIndex>
pub fn colormap_index_by_name(&self, name: &str) -> Option<ColormapIndex>
Look up a colormap index by its name.
Sourcepub fn colormap_size(&self, index: impl Into<ColormapIndex>) -> usize
pub fn colormap_size(&self, index: impl Into<ColormapIndex>) -> usize
Return the number of color entries in a colormap.
Sourcepub fn style_colormap_index(&self) -> Option<ColormapIndex>
pub fn style_colormap_index(&self) -> Option<ColormapIndex>
Return the default colormap stored in this ImPlot context’s style.
Sourcepub fn style_colormap_name(&self) -> Option<String>
pub fn style_colormap_name(&self) -> Option<String>
Return this context’s default colormap name.
Sourcepub fn set_style_colormap(&self, index: impl Into<ColormapIndex>)
pub fn set_style_colormap(&self, index: impl Into<ColormapIndex>)
Permanently set the default colormap used by this ImPlot context.
Sourcepub fn set_style_colormap_by_name(&self, name: &str)
pub fn set_style_colormap_by_name(&self, name: &str)
Permanently set the default colormap by name. Invalid names are ignored.
Sourcepub fn colormap_color(&self, index: ColormapColorIndex) -> [f32; 4]
pub fn colormap_color(&self, index: ColormapColorIndex) -> [f32; 4]
Return a color from this context’s active colormap.
Sourcepub fn colormap_color_from(
&self,
index: ColormapColorIndex,
cmap: impl Into<ColormapIndex>,
) -> [f32; 4]
pub fn colormap_color_from( &self, index: ColormapColorIndex, cmap: impl Into<ColormapIndex>, ) -> [f32; 4]
Return a color from a selected colormap.
Sourcepub fn sample_colormap(&self, t: f32) -> [f32; 4]
pub fn sample_colormap(&self, t: f32) -> [f32; 4]
Sample this context’s active colormap at t in [0, 1].
Sourcepub fn sample_colormap_from(
&self,
t: f32,
cmap: impl Into<ColormapSelection>,
) -> [f32; 4]
pub fn sample_colormap_from( &self, t: f32, cmap: impl Into<ColormapSelection>, ) -> [f32; 4]
Sample a selected colormap at t in [0, 1].
Sourcepub fn next_colormap_color(&self) -> [f32; 4]
pub fn next_colormap_color(&self) -> [f32; 4]
Return the next color from this context’s current colormap and advance its color cursor.
Sourcepub fn map_input_default(&self)
pub fn map_input_default(&self)
Map this context’s input scheme to ImPlot defaults.
Sourcepub fn map_input_reverse(&self)
pub fn map_input_reverse(&self)
Map this context’s input scheme to ImPlot’s reversed scheme.