Skip to main content

PlotContext

Struct PlotContext 

Source
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

Source

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.

Source

pub fn create(imgui_ctx: &ImGuiContext) -> Self

Create a new ImPlot context (panics on error)

Source

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.

Source

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

Source

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.

Source

pub fn colormap_count(&self) -> usize

Return the number of available colormaps.

Source

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.

Source

pub fn colormap_index_by_name(&self, name: &str) -> Option<ColormapIndex>

Look up a colormap index by its name.

Source

pub fn colormap_size(&self, index: impl Into<ColormapIndex>) -> usize

Return the number of color entries in a colormap.

Source

pub fn style_colormap_index(&self) -> Option<ColormapIndex>

Return the default colormap stored in this ImPlot context’s style.

Source

pub fn style_colormap_name(&self) -> Option<String>

Return this context’s default colormap name.

Source

pub fn set_style_colormap(&self, index: impl Into<ColormapIndex>)

Permanently set the default colormap used by this ImPlot context.

Source

pub fn set_style_colormap_by_name(&self, name: &str)

Permanently set the default colormap by name. Invalid names are ignored.

Source

pub fn colormap_color(&self, index: ColormapColorIndex) -> [f32; 4]

Return a color from this context’s active colormap.

Source

pub fn colormap_color_from( &self, index: ColormapColorIndex, cmap: impl Into<ColormapIndex>, ) -> [f32; 4]

Return a color from a selected colormap.

Source

pub fn sample_colormap(&self, t: f32) -> [f32; 4]

Sample this context’s active colormap at t in [0, 1].

Source

pub fn sample_colormap_from( &self, t: f32, cmap: impl Into<ColormapSelection>, ) -> [f32; 4]

Sample a selected colormap at t in [0, 1].

Source

pub fn next_colormap_color(&self) -> [f32; 4]

Return the next color from this context’s current colormap and advance its color cursor.

Source

pub fn map_input_default(&self)

Map this context’s input scheme to ImPlot defaults.

Source

pub fn map_input_reverse(&self)

Map this context’s input scheme to ImPlot’s reversed scheme.

Trait Implementations§

Source§

impl Drop for PlotContext

Source§

fn drop(&mut self)

Executes the destructor for this type. Read more
Source§

fn pin_drop(self: Pin<&mut Self>)

🔬This is a nightly-only experimental API. (pin_ergonomics)
Execute the destructor for this type, but different to Drop::drop, it requires self to be pinned. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more