InsetAxes

Struct InsetAxes 

Source
pub struct InsetAxes { /* private fields */ }
Expand description

Implements the capability to add inset Axes to existing Axes.

§Examples

use plotpy::{Curve, InsetAxes, Plot, StrError};

fn main() -> Result<(), StrError> {
    // draw curve
    let mut curve = Curve::new();
    curve.draw(&[0.0, 1.0, 2.0], &[0.0, 1.0, 4.0]);

    // allocate inset and add curve to it
    let mut inset = InsetAxes::new();
    inset
        .add(&curve) // add curve to inset
        .set_range(0.5, 1.5, 0.5, 1.5) // set the range of the inset
        .draw(0.5, 0.5, 0.4, 0.3);

    // add curve and inset to plot
    let mut plot = Plot::new();
    plot.add(&curve)
        .set_range(0.0, 5.0, 0.0, 5.0)
        .add(&inset) // IMPORTANT: add inset after setting the range
        .save("/tmp/plotpy/doc_tests/doc_inset_axes_add.svg")
}

doc_inset_axes_add.svg

§Warning

WARNING: If the range of axes has been modified in crate::Plot, e.g. by plot.set_range(...), then the inset must be added after the range has been set. Otherwise, the inset will not be displayed correctly. Specifically the connector lines will not be drawn if the inset is added before set_range.

Implementations§

Source§

impl InsetAxes

Source

pub fn new() -> Self

Creates a new InsetAxes object with an empty buffer.

§Returns

A new instance of InsetAxes.

§Warning

WARNING: If the range of axes has been modified in crate::Plot, e.g. by plot.set_range(...), then the inset must be added after the range has been set. Otherwise, the inset will not be displayed correctly. Specifically the connector lines will not be drawn if the inset is added before set_range.

For example, below is the correct procedure:

use plotpy::{InsetAxes, Plot};
let mut inset = InsetAxes::new();
let mut plot = Plot::new();
plot.set_range(0.0, 10.0, 0.0, 10.0)
    .add(&inset); // IMPORTANT: add inset after setting the range
Source

pub fn set_indicator_line_style(&mut self, style: &str) -> &mut Self

Sets the line style for the indicator (e.g. “–”, “:”, “-.”)

Source

pub fn set_indicator_line_color(&mut self, color: &str) -> &mut Self

Sets the line color for the indicator (e.g. “red”, “#FF0000”)

Source

pub fn set_indicator_line_width(&mut self, width: f64) -> &mut Self

Sets the line width for the indicator

Source

pub fn set_indicator_alpha(&mut self, alpha: f64) -> &mut Self

Sets the alpha (opacity) for the indicator

Source

pub fn set_indicator_hatch(&mut self, hatch: &str) -> &mut Self

Sets the hatch pattern for the indicator (e.g. “/”, “\”, “|”, “-”, “+”, “x”, “o”, “O”, “.”, “*”)

Common hatch patterns include:

  • “/” - diagonal hatching
  • “" - back diagonal hatching
  • “|” - vertical hatching
  • “-” - horizontal hatching
  • “+” - crossed hatching
  • “x” - crossed diagonal hatching
  • “o” - small circle hatching
  • “O” - large circle hatching
  • “.” - dot hatching
  • “*” - star hatching

See options in

See Matplotlib’s documentation for more hatch patterns

Source

pub fn add(&mut self, graph: &dyn GraphMaker) -> &mut Self

Adds new graph entity

§Warning

WARNING: If the range of axes has been modified in crate::Plot, e.g. by plot.set_range(...), then the inset must be added after the range has been set. Otherwise, the inset will not be displayed correctly. Specifically the connector lines will not be drawn if the inset is added before set_range.

For example, below is the correct procedure:

use plotpy::{InsetAxes, Plot};
let mut inset = InsetAxes::new();
let mut plot = Plot::new();
plot.set_range(0.0, 10.0, 0.0, 10.0)
    .add(&inset); // IMPORTANT: add inset after setting the range
Source

pub fn draw(&mut self, u0: f64, v0: f64, width: f64, height: f64)

Draws the inset Axes.

Example of normalized coordinates: (0.5, 0.5, 0.4, 0.3).

§Arguments
  • u0 – The normalized (0 to 1) horizontal figure coordinate of the lower-left corner of the inset Axes.
  • v0 – The normalized (0 to 1) vertical figure coordinate of the lower-left corner of the inset Axes.
  • width – The width of the inset Axes.
  • height – The height of the inset Axes.
§Warning

WARNING: If the range of axes has been modified in crate::Plot, e.g. by plot.set_range(...), then the inset must be added after the range has been set. Otherwise, the inset will not be displayed correctly. Specifically the connector lines will not be drawn if the inset is added before set_range.

Source

pub fn set_range( &mut self, xmin: f64, xmax: f64, ymin: f64, ymax: f64, ) -> &mut Self

Sets the limits of axes in the inset.

Source

pub fn set_extra_for_axes(&mut self, extra: &str) -> &mut Self

Sets extra Matplotlib commands for the inset Axes (comma separated).

See Matplotlib’s documentation for extra parameters

Source

pub fn set_extra_for_indicator(&mut self, extra: &str) -> &mut Self

Sets extra Matplotlib commands for the indicator (comma separated).

See Matplotlib’s documentation for extra parameters

Source

pub fn set_visibility(&mut self, visible: bool) -> &mut Self

Sets the visibility of the axes ticks

§Arguments
  • visible - If true, shows the axes ticks. If false, hides them.
Source

pub fn set_title(&mut self, title: &str) -> &mut Self

Sets the title of the inset axes

Source

pub fn set_indicator_disabled(&mut self, disabled: bool) -> &mut Self

Sets whether the indicator lines are disabled

§Arguments
  • disabled - If true, hides the indicator lines. If false, shows them.

Trait Implementations§

Source§

impl GraphMaker for InsetAxes

Source§

fn get_buffer<'a>(&'a self) -> &'a String

Returns a reference to the buffer containing the generated commands.

§Returns

A reference to the buffer as a String.

Source§

fn clear_buffer(&mut self)

Clears the buffer, removing all stored commands.

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