gnuplot/coordinates.rs
1// Copyright (c) 2013-2014 by SiegeLord
2//
3// All rights reserved. Distributed under LGPL 3.0. For full terms see the file LICENSE.
4
5pub use self::Coordinate::*;
6use std::fmt;
7
8/// Specifies how to interpret the coordinate passed to a plotting command
9#[derive(Copy, Clone)]
10pub enum Coordinate
11{
12 /// Coordinates are done relative to a graph (i.e. an axis set). (0, 0) is the bottom left corner and (1, 1) is the top right corner.
13 /// You'd use this to place labels and other objects so that they remain in the same place relative to the graph no matter what you have plotted.
14 Graph(f64),
15 /// Coordinates match those on the axes. You'd use this to place labels and other objects relative to regions of interest in the graph (e.g. labeling the peak of a function)
16 Axis(f64),
17 /// Coordinates match those on the secondary axes. You'd use this to place labels and other objects relative to regions of interest in the graph (e.g. labeling the peak of a function)
18 Axis2(f64),
19}
20
21impl fmt::Display for Coordinate
22{
23 fn fmt(&self, buf: &mut fmt::Formatter) -> fmt::Result
24 {
25 let (name, x) = match *self
26 {
27 Graph(x) => (" graph ", x),
28 Axis(x) => (" first ", x),
29 Axis2(x) => (" second ", x),
30 };
31 write!(buf, "{}{:.16e}", name, x)
32 }
33}