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")
}§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
impl InsetAxes
Sourcepub fn new() -> Self
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 rangeSourcepub fn set_indicator_line_style(&mut self, style: &str) -> &mut Self
pub fn set_indicator_line_style(&mut self, style: &str) -> &mut Self
Sets the line style for the indicator (e.g. “–”, “:”, “-.”)
Sourcepub fn set_indicator_line_color(&mut self, color: &str) -> &mut Self
pub fn set_indicator_line_color(&mut self, color: &str) -> &mut Self
Sets the line color for the indicator (e.g. “red”, “#FF0000”)
Sourcepub fn set_indicator_line_width(&mut self, width: f64) -> &mut Self
pub fn set_indicator_line_width(&mut self, width: f64) -> &mut Self
Sets the line width for the indicator
Sourcepub fn set_indicator_alpha(&mut self, alpha: f64) -> &mut Self
pub fn set_indicator_alpha(&mut self, alpha: f64) -> &mut Self
Sets the alpha (opacity) for the indicator
Sourcepub fn set_indicator_hatch(&mut self, hatch: &str) -> &mut Self
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
Sourcepub fn add(&mut self, graph: &dyn GraphMaker) -> &mut Self
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 rangeSourcepub fn draw(&mut self, u0: f64, v0: f64, width: f64, height: f64)
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.
Sourcepub fn set_range(
&mut self,
xmin: f64,
xmax: f64,
ymin: f64,
ymax: f64,
) -> &mut Self
pub fn set_range( &mut self, xmin: f64, xmax: f64, ymin: f64, ymax: f64, ) -> &mut Self
Sets the limits of axes in the inset.
Sourcepub fn set_extra_for_axes(&mut self, extra: &str) -> &mut Self
pub fn set_extra_for_axes(&mut self, extra: &str) -> &mut Self
Sets extra Matplotlib commands for the inset Axes (comma separated).
Sourcepub fn set_extra_for_indicator(&mut self, extra: &str) -> &mut Self
pub fn set_extra_for_indicator(&mut self, extra: &str) -> &mut Self
Sets extra Matplotlib commands for the indicator (comma separated).
Sourcepub fn set_visibility(&mut self, visible: bool) -> &mut Self
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.
Sourcepub fn set_indicator_disabled(&mut self, disabled: bool) -> &mut Self
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
impl GraphMaker for InsetAxes
Source§fn get_buffer<'a>(&'a self) -> &'a String
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)
fn clear_buffer(&mut self)
Clears the buffer, removing all stored commands.