Struct gnuplot::Figure

source ·
pub struct Figure { /* private fields */ }
Expand description

A figure that may contain multiple axes.

Implementations§

source§

impl Figure

source

pub fn new() -> Figure

Creates a new figure.

source

pub fn set_data_directory( &mut self, data_directory: Option<String> ) -> &mut Self

Set the directory where to write the data.

Gnuplot needs to reify the data before it can be plotted. By default, this is done by writing out data files into a temporary directory. This behavior can be restored by passing in Some("".into()).

This can be set to None, in which case the data is written inline, without a temporary directory. Note that this has somewhat spotty support in gnuplot, so should probably be avoided.

source

pub fn set_terminal<'l>( &'l mut self, terminal: &str, output_file: &str ) -> &'l mut Figure

Sets the terminal for gnuplot to use, as well as the file to output the figure to. Terminals that spawn a GUI don’t need an output file, so pass an empty string for those.

There are a quite a number of terminals, here are some commonly used ones:

  • wxt - Interactive GUI
  • pdfcairo - Saves the figure as a PDF file
  • epscairo - Saves the figure as a EPS file
  • pngcairo - Saves the figure as a PNG file
  • svg - Saves the figure as a SVG file
  • canvas - Saves the figure as an HTML5 canvas element

As of now you can hack the canvas size in by using “pngcairo size 600, 400” for terminal. Be prepared for that kludge to go away, though.

source

pub fn set_enhanced_text(&mut self, enhanced: bool) -> &mut Figure

Set or unset text enhancements

source

pub fn set_post_commands(&mut self, post_commands: &str) -> &mut Figure

Sets commands to send to gnuplot after all the plotting commands.

source

pub fn set_pre_commands(&mut self, pre_commands: &str) -> &mut Figure

Sets commands to send to gnuplot before any plotting commands.

source

pub fn set_gnuplot_version( &mut self, version: Option<GnuplotVersion> ) -> &mut Figure

Sets the Gnuplot version.

By default, we assume version 5.0. If show is called, it will attempt to parse Gnuplot’s version string as well.

source

pub fn get_gnuplot_version(&self) -> GnuplotVersion

Returns the Gnuplot version.

source

pub fn set_multiplot_layout(&mut self, rows: usize, columns: usize) -> &mut Self

Define the layout for the multiple plots

§Arguments
  • rows - Number of rows
  • columns - Number of columns
source

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

Set the multiplot title

§Arguments
  • title - Name of the file
source

pub fn set_scale(&mut self, scale_x: f32, scale_y: f32) -> &mut Self

Applies a horizontal and vertical scale to each plot

§Arguments
  • scale_x - Horizonal scale applied to each plot
  • scale_y - Vertical scale applied to each plot
source

pub fn set_offset(&mut self, offset_x: f32, offset_y: f32) -> &mut Self

Applies a horizontal and vertical offset to each plot

§Arguments
  • offset_x - Horizontal offset applied to each plot
  • offset_y - Horizontal offset applied to each plot
source

pub fn set_multiplot_fill_order( &mut self, order: MultiplotFillOrder, direction: MultiplotFillDirection ) -> &mut Self

Defines the order in which plots fill the layout. Default is RowsFirst and Downwards.

§Arguments
  • order - Options: RowsFirst, ColumnsFirst
  • direction - Options: Downwards, Upwards
source

pub fn axes2d(&mut self) -> &mut Axes2D

Creates a set of 2D axes

source

pub fn axes3d(&mut self) -> &mut Axes3D

Creates a set of 3D axes

source

pub fn new_page(&mut self) -> &mut Figure

Creates a new page.

Some terminals support multiple pages or frames, e.g. to create an animation. Call this function between sets of plots to indicate that a new page should be started. Note that this is implicit before any axes2d/axes3d calls, so make sure to call this only between pages (not once before every page).

source

pub fn show_and_keep_running(&mut self) -> Result<&mut Figure, GnuplotInitError>

Launch a gnuplot process, if it hasn’t been spawned already by a call to this function, and display the figure on it.

Usually you should prefer using show instead. This method is primarily useful when you wish to call this multiple times, e.g. to redraw an existing plot window.

source

pub fn show(&mut self) -> Result<CloseSentinel, GnuplotInitError>

Launch a gnuplot process, if it hasn’t been spawned already and display the figure on it.

Unlike show_and_keep_running, this also instructs gnuplot to close if you close all of the plot windows. You can use the returned CloseSentinel to wait until this happens.

source

pub fn save_to_png<P: AsRef<Path>>( &mut self, filename: P, width_px: u32, height_px: u32 ) -> Result<(), GnuplotInitError>

Save the figure to a png file.

§Arguments
  • filename - Path to the output file (png)
  • width_px - output image width (in pixels)
  • height_px - output image height (in pixels)
source

pub fn save_to_svg<P: AsRef<Path>>( &mut self, filename: P, width_px: u32, height_px: u32 ) -> Result<(), GnuplotInitError>

Save the figure to a svg file.

§Arguments
  • filename - Path to the output file (svg)
  • width_px - output image width (in pixels)
  • height_px - output image height (in pixels)
source

pub fn save_to_pdf<P: AsRef<Path>>( &mut self, filename: P, width_in: f32, height_in: f32 ) -> Result<(), GnuplotInitError>

Save the figure to a pdf file.

§Arguments
  • filename - Path to the output file (pdf)
  • width_in - output image width (in inches)
  • height_in - output image height (in inches)
source

pub fn save_to_eps<P: AsRef<Path>>( &mut self, filename: P, width_in: f32, height_in: f32 ) -> Result<(), GnuplotInitError>

Save the figure to an eps file

§Arguments
  • filename - Path to the output file (eps)
  • width_in - output image width (in inches)
  • height_in - output image height (in inches)
source

pub fn save_to_canvas<P: AsRef<Path>>( &mut self, filename: P, width_px: u32, height_px: u32 ) -> Result<(), GnuplotInitError>

Save the figure to a HTML5 canvas file

§Arguments
  • filename - Path to the output file (canvas)
  • width_px - output image width (in pixels)
  • height_px - output image height (in pixels)
source

pub fn close(&mut self) -> &mut Figure

Closes the gnuplot process.

This can be useful if you’re your plot output is a file and you need to that it was written.

source

pub fn clear_axes(&mut self) -> &mut Figure

Clears all axes on this figure.

source

pub fn echo<T: Writer>(&self, writer: &mut T) -> &Figure

Echo the commands that if piped to a gnuplot process would display the figure

§Arguments
  • writer - A function pointer that will be called multiple times with the command text and data
source

pub fn echo_to_file<P: AsRef<Path>>(&self, filename: P) -> &Figure

Save to a file the the commands that if piped to a gnuplot process would display the figure

§Arguments
  • filename - Name of the file

Trait Implementations§

source§

impl Default for Figure

source§

fn default() -> Self

Returns the “default value” for a type. Read more
source§

impl Drop for Figure

source§

fn drop(&mut self)

Executes the destructor for this type. Read more

Auto Trait Implementations§

§

impl Freeze for Figure

§

impl RefUnwindSafe for Figure

§

impl Send for Figure

§

impl Sync for Figure

§

impl Unpin for Figure

§

impl UnwindSafe for Figure

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

§

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

§

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.