pub struct Image { /* private fields */ }Expand description
Generates an image plot (imshow)
See Matplotlib’s documentation
§Examples
use plotpy::{Image, Plot, StrError};
fn main() -> Result<(), StrError> {
// set values
let data = [
[0.8, 2.4, 2.5, 3.9, 0.0, 4.0, 0.0],
[2.4, 0.0, 4.0, 1.0, 2.7, 0.0, 0.0],
[1.1, 2.4, 0.8, 4.3, 1.9, 4.4, 0.0],
[0.6, 0.0, 0.3, 0.0, 3.1, 0.0, 0.0],
[0.7, 1.7, 0.6, 2.6, 2.2, 6.2, 0.0],
[1.3, 1.2, 0.0, 0.0, 0.0, 3.2, 5.1],
[0.1, 2.0, 0.0, 1.4, 0.0, 1.9, 6.3],
];
// image plot and options
let mut img = Image::new();
img.set_colormap_name("hsv").draw(&data);
// save figure
let mut plot = Plot::new();
plot.add(&img);
plot.save("/tmp/plotpy/doc_tests/doc_image_1.svg")?;
Ok(())
}See also integration test in the tests directory.
Implementations§
Source§impl Image
impl Image
Sourcepub fn draw<'a, T, U>(&mut self, data: &'a T)
pub fn draw<'a, T, U>(&mut self, data: &'a T)
(imshow) Displays data as an image
§Arguments
data- 2D matrix-like data structure
See https://matplotlib.org/stable/api/_as_gen/matplotlib.pyplot.imshow.html
Sourcepub fn draw_rgb_or_rgba<T>(&mut self, data: &Vec<Vec<Vec<T>>>)
pub fn draw_rgb_or_rgba<T>(&mut self, data: &Vec<Vec<Vec<T>>>)
(imshow) Displays data as an image with RGB or RGB(A) values
§Arguments
data- 3D vector with shape (height, width, 3) for RGB or (height, width, 4) for RGBA The inner-most vector contains the color channels.
See https://matplotlib.org/stable/api/_as_gen/matplotlib.pyplot.imshow.html
Sourcepub fn set_colormap_index(&mut self, index: usize) -> &mut Self
pub fn set_colormap_index(&mut self, index: usize) -> &mut Self
Sets the colormap index
Options:
- 0 – bwr
- 1 – RdBu
- 2 – hsv
- 3 – jet
- 4 – terrain
- 5 – pink
- 6 – Greys
>6 – starts over from 0
Sourcepub fn set_colormap_name(&mut self, name: &str) -> &mut Self
pub fn set_colormap_name(&mut self, name: &str) -> &mut Self
Sets the colormap name
Colormap names:
Will use colormap_index instead if colormap_name is empty.
pub fn set_extra(&mut self, extra: &str) -> &mut Self
Trait Implementations§
Source§impl GraphMaker for Image
impl GraphMaker for Image
Source§fn get_buffer<'a>(&'a self) -> &'a String
fn get_buffer<'a>(&'a self) -> &'a String
Returns the text buffer with Python3 commands
Source§fn clear_buffer(&mut self)
fn clear_buffer(&mut self)
Clear the text buffer with Python commands
Auto Trait Implementations§
impl Freeze for Image
impl RefUnwindSafe for Image
impl Send for Image
impl Sync for Image
impl Unpin for Image
impl UnwindSafe for Image
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more