pub struct Plot {Show 23 fields
pub plot_coord_mouse_pos: Vec2,
pub canvas_position: Vec2,
pub tick_period: Vec2,
pub outer_border: Vec2,
pub canvas_size: Vec2,
pub background_color1: Color,
pub background_color2: Color,
pub show_grid: bool,
pub zero_world: Vec2,
pub time: f32,
pub zoom: f32,
pub hide_contour: bool,
pub hide_tick_labels: bool,
pub hide_half_ticks: bool,
pub tick_label_color: Color,
pub significant_digits: usize,
pub show_target: bool,
pub target_label_color: Color,
pub target_color: Color,
pub target_significant_digits: usize,
pub show_axes: bool,
pub bezier_num_points: usize,
pub data: PlotData,
/* private fields */
}Expand description
Contains all relevant information to both the look of the canvas and the data to be plotted.
Fields
plot_coord_mouse_pos: Vec2mouse position in the reference frame of the graph, corresponding to its axes
canvas_position: Vec2Position of the canvas in World coordinates
tick_period: Vec2Distance between consecutive grid lines
outer_border: Vec2Size of the margins with respect to the canvas_size. The default is set to Vec2::new(0.03 * size.y / size.x, 0.03)
canvas_size: Vec2Size of the graph in pixels
background_color1: ColorColor of even tiles
background_color2: ColorColor of odd tiles
show_grid: boolThe grid is shown by default
zero_world: Vec2Position of the origin of the graph in World coordinates
time: f32unused
zoom: f32The current zoom value: adjustable with the MouseWheel
hide_contour: boolHides the black contour around the canvas
hide_tick_labels: boolHides numeric labels by the side of the grid lines
hide_half_ticks: boolHides half the numeric tick labels for a less crowded feel
tick_label_color: ColorColor for the numerical labels shown by the side of the grid lines
significant_digits: usizeAdjusts the number of significant digits for the tick labels
show_target: boolA target can be spawned together with a pair of coordinates by pressing MouseButton::Middle
target_label_color: ColorThe color for the coordinate pair by the side of the target
target_color: ColorColor of the target
target_significant_digits: usizeNumber of significant digits for the target coordinates
show_axes: boolAxes are shown by default
bezier_num_points: usizeThe number of samples taken on the explicit function provided to Plot::plot_func or [Plot::plotopt_func`] functions
data: PlotDataContains the data and metaparameters needed for drawing each kind of plot
Implementations
sourceimpl Plot
impl Plot
sourcepub fn plotopt<T: Plotable>(&mut self, v: T, options: Vec<Opt>)
pub fn plotopt<T: Plotable>(&mut self, v: T, options: Vec<Opt>)
Customizable plotting function. Takes any type that implements Plotable, namely
Vec<Vec2>, Vec<(f64, f64)>, Vec<f32>, …
sourcepub fn plot(&mut self, v: impl Plotable)
pub fn plot(&mut self, v: impl Plotable)
Quickly plot data points using segments to connect consecutive points. Takes any type
that implements Plotable, namely Vec<Vec2>, Vec<(f64, f64)>, Vec<f32>, …
sourcepub fn plotm<T: Plotable>(&mut self, v: T)
pub fn plotm<T: Plotable>(&mut self, v: T)
Quickly plot data points using markers (scatter plot).
sourcepub fn plot_func(&mut self, f: fn(_: f32, _: f32) -> f32)
pub fn plot_func(&mut self, f: fn(_: f32, _: f32) -> f32)
Quickly plot a function by providing said function. Defaults to a range on the both axes from -0.2 to 1.2.
sourcepub fn plotopt_func(&mut self, f: fn(_: f32, _: f32) -> f32, options: Vec<Opt>)
pub fn plotopt_func(&mut self, f: fn(_: f32, _: f32) -> f32, options: Vec<Opt>)
Plot a function by providing said function and options.
sourcepub fn set_bounds(&mut self, lo: Vec2, up: Vec2)
pub fn set_bounds(&mut self, lo: Vec2, up: Vec2)
Override the default plot bounds: x axis goes from bounds.lo.x to bounds.up.x. Beware! The tick period is automatically adjusted. Changing the tick period before setting the bounds will not have the intended effect. The bounds must be set before the ticks.
Panics
Panics if lo.x >= up.x or lo.y >= up.y.
sourcepub fn to_local(&self, v: Vec2) -> Vec2
pub fn to_local(&self, v: Vec2) -> Vec2
Convert a point in plot coordinates to a point in world coordinates modulo the canvas position
sourcepub fn world_to_plot(&self, y: Vec2) -> Vec2
pub fn world_to_plot(&self, y: Vec2) -> Vec2
Convert a point in world coordinates to a point in the graph coordinates.
Trait Implementations
Auto Trait Implementations
impl RefUnwindSafe for Plot
impl Send for Plot
impl Sync for Plot
impl Unpin for Plot
impl UnwindSafe for Plot
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcepub fn borrow_mut(&mut self) -> &mut T
pub fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
impl<T> Downcast for T where
T: Any,
impl<T> Downcast for T where
T: Any,
pub fn into_any(self: Box<T, Global>) -> Box<dyn Any + 'static, Global>
pub fn into_any(self: Box<T, Global>) -> Box<dyn Any + 'static, Global>
Convert Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>. Box<dyn Any> can
then be further downcast into Box<ConcreteType> where ConcreteType implements Trait. Read more
pub fn into_any_rc(self: Rc<T>) -> Rc<dyn Any + 'static>
pub fn into_any_rc(self: Rc<T>) -> Rc<dyn Any + 'static>
Convert Rc<Trait> (where Trait: Downcast) to Rc<Any>. Rc<Any> can then be
further downcast into Rc<ConcreteType> where ConcreteType implements Trait. Read more
pub fn as_any(&self) -> &(dyn Any + 'static)
pub fn as_any(&self) -> &(dyn Any + 'static)
Convert &Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &Any’s vtable from &Trait’s. Read more
pub fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
pub fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
Convert &mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &mut Any’s vtable from &mut Trait’s. Read more
impl<T> FromWorld for T where
T: Default,
impl<T> FromWorld for T where
T: Default,
pub fn from_world(_world: &mut World) -> T
pub fn from_world(_world: &mut World) -> T
Creates Self using data from the given [World]
sourceimpl<T> Instrument for T
impl<T> Instrument for T
sourcefn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
sourcefn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
sourceimpl<T> ToOwned for T where
T: Clone,
impl<T> ToOwned for T where
T: Clone,
type Owned = T
type Owned = T
The resulting type after obtaining ownership.
sourcepub fn to_owned(&self) -> T
pub fn to_owned(&self) -> T
Creates owned data from borrowed data, usually by cloning. Read more
sourcepub fn clone_into(&self, target: &mut T)
pub fn clone_into(&self, target: &mut T)
toowned_clone_into)Uses borrowed data to replace owned data, usually by cloning. Read more
impl<T> TypeData for T where
T: 'static + Send + Sync + Clone,
impl<T> TypeData for T where
T: 'static + Send + Sync + Clone,
pub fn clone_type_data(&self) -> Box<dyn TypeData + 'static, Global>
impl<V, T> VZip<V> for T where
V: MultiLane<T>,
impl<V, T> VZip<V> for T where
V: MultiLane<T>,
pub fn vzip(self) -> V
sourceimpl<T> WithSubscriber for T
impl<T> WithSubscriber for T
sourcefn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> where
S: Into<Dispatch>,
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
sourcefn with_current_subscriber(self) -> WithDispatch<Self>
fn with_current_subscriber(self) -> WithDispatch<Self>
Attaches the current default Subscriber to this type, returning a
WithDispatch wrapper. Read more