1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288
// Copyright (c) 2013-2014 by SiegeLord // // All rights reserved. Distributed under LGPL 3.0. For full terms see the file LICENSE. pub use self::PlotOption::*; pub use self::FillRegionType::*; pub use self::AlignType::*; pub use self::DashType::*; pub use self::ArrowheadType::*; pub use self::AutoOption::*; pub use self::LabelOption::*; pub use self::TickOption::*; pub use self::Tick::*; pub use self::BorderLocation2D::*; pub use self::LegendOption::*; pub use self::ContourStyle::*; pub use self::PaletteType::*; /// An enumeration of plot options you can supply to plotting commands, governing /// things like line width, color and others #[derive(Copy, Clone)] pub enum PlotOption<'l> { /// Sets the symbol used for points. The valid characters are as follows: /// /// * `.` - dot /// * `+` - plus /// * `x` - cross /// * `*` - star /// * `s` - empty square /// * `S` - filled square /// * `o` - empty circle /// * `O` - filled circle /// * `t` - empty triangle /// * `T` - filled triangle /// * `d` - empty del (upside down triangle) /// * `D` - filled del (upside down triangle) /// * `r` - empty rhombus /// * `R` - filled rhombus PointSymbol(char), /// Sets the size of the points. The size acts as a multiplier, with 1.0 being the default. PointSize(f64), /// Sets the caption of the plot element. Set to empty to hide it from the legend. Caption(&'l str), /// Sets the width of lines. LineWidth(f64), /// Sets the color of the plot element. The passed string can be a color name /// (e.g. "black" works), or an HTML color specifier (e.g. "#FFFFFF" is white). This specifies the fill color of a filled plot. Color(&'l str), /// Sets the color of the border of a filled plot (if it has one). The passed string can be a color name /// (e.g. "black" works), or an HTML color specifier (e.g. "#FFFFFF" is white). BorderColor(&'l str), /// Sets the style of the line. Note that not all gnuplot terminals support dashed lines. See DashType for the available styles. LineStyle(DashType), /// Sets the transparency of a filled plot. `0.0` - fully transparent, `1.0` - fully opaque FillAlpha(f64), /// Sets the fill region. See FillRegion for the available regions. FillRegion(FillRegionType), /// Sets what an arrowhead looks like ArrowType(ArrowheadType), /// Sets the size of the arrowhead. This is specified in the units of graph (i.e. `1.0` would make the arrow as big as the graph). ArrowSize(f64), } /// An enumeration of possible fill regions #[derive(Copy, Clone)] pub enum FillRegionType { Above, Below, Between } /// An enumeration of possible text and label alignments #[derive(Copy, Clone)] pub enum AlignType { AlignLeft, AlignRight, AlignCenter, AlignTop, AlignBottom } /// An enumeration of possible dash styles #[derive(Copy, Clone)] pub enum DashType { Solid, SmallDot, Dot, Dash, DotDash, DotDotDash } impl DashType { pub fn to_int(&self) -> i32 { match *self { Solid => 1, SmallDot => 0, Dash => 2, Dot => 3, DotDash => 4, DotDotDash => 5 } } } /// An enumeration of possible arrow head styles #[derive(Copy, Clone)] pub enum ArrowheadType { /// An arrow head shaped like a 'V' Open, /// An arrow head shaped like an outlined triangle Closed, /// An arrow head shaped like a filled triangle Filled, /// No arrow head NoArrow, } /// An enumeration of something that can either be fixed (e.g. the maximum of X values), /// or automatically determined #[derive(Copy, Clone)] pub enum AutoOption<T> { /// Fixes the value to a specific value Fix(T), /// Lets the value scale automatically Auto } impl<T> AutoOption<T> { /// Same as `Option::map` pub fn map<U, F: FnOnce(T) -> U>(self, f: F) -> AutoOption<U> { match self { Fix(v) => Fix(f(v)), Auto => Auto } } } /// An enumeration of label options that control label attributes #[derive(Copy, Clone)] pub enum LabelOption<'l> { /// Sets the offset of the label in characters TextOffset(f64, f64), /// Sets the font of the label. The string specifies the font type (e.g. "Arial") and the number specifies the size (the units are terminal dependent, but are often points) Font(&'l str, f64), /// Sets the color of the label text. The passed string can be a color name /// (e.g. "black" works), or an HTML color specifier (e.g. "#FFFFFF" is white) TextColor(&'l str), /// Rotates the label by a certain number of degrees Rotate(f64), /// Sets the horizontal alignment of the label text (default is left alignment). See AlignType. TextAlign(AlignType), /// Sets a marker for the label. By default no marker is drawn. The valid characters are as follows: /// /// * `.` - dot /// * `+` - plus /// * `x` - cross /// * `*` - star /// * `s` - empty square /// * `S` - filled square /// * `o` - empty circle /// * `O` - filled circle /// * `t` - empty triangle /// * `T` - filled triangle /// * `d` - empty del (upside down triangle) /// * `D` - filled del (upside down triangle) /// * `r` - empty rhombus /// * `R` - filled rhombus MarkerSymbol(char), /// Sets the color of the marker. The passed string can be a color name /// (e.g. "black" works), or an HTML color specifier (e.g. "#FFFFFF" is white) MarkerColor(&'l str), /// Sets the size of the marker. The size acts as a multiplier, with 1.0 being the default. MarkerSize(f64), } /// An enumeration of axis tick options #[derive(Copy, Clone)] pub enum TickOption { /// Specifies whether the ticks are drawn at the borders of the plot, or on the axis OnAxis(bool), /// If the axes are drawn on the border, this specifies whether to draw the ticks on the opposite border as well Mirror(bool), /// If the axes are drawn on the border, this specifies whether to draw the ticks pointing inward or outward Inward(bool), /// Sets the scale of the minor ticks MinorScale(f64), /// Sets the scale of the major ticks MajorScale(f64) } /// Specifies a type of axis tick pub enum Tick<T> { /// Major ticks have position and an optional label. The label may have a single C-style format specifier which will be replaced by the location of the tick Major(T, AutoOption<String>), /// Minor ticks only have position Minor(T) } /// Plot border locations #[derive(Copy, Clone)] pub enum BorderLocation2D { Bottom = 1, Left = 2, Top = 4, Right = 8 } /// Legend options #[derive(Copy, Clone)] pub enum LegendOption<'l> { /// Puts curve samples to the left of the label Reverse, /// Displays legend entries in opposite order Invert, /// Makes the legend horizontal (default is vertical) Horizontal, /// Specifies the location of the legend. The first argument specifies the horizontal /// placement with respect to its position, and the second argument specifies the vertical placement Placement(AlignType, AlignType), /// Title of the legend Title(&'l str), /// Specifies the maximum number of rows, when the legend is vertical MaxRows(u32), /// Specifies the maximum number of columns, when the legend is horizontal MaxCols(u32), } /// Specifies how the contours are drawn #[derive(Copy, Clone)] pub enum ContourStyle { /// Draw lines between points of equal value Linear, /// Draw somewhat smoother curves between points with equal value. /// /// The argument specifies the number of points to use to approximate the /// curve for the final drawing step (clamped to range from 2 to 100). Cubic(u32), /// Draw an even smoother curve, this time approximating the locations of /// points with equal value (clamped to range from 2 to 100). /// /// The first argument specifies the number of points to use to approximate /// the curve for the final drawing step. The second argument specifies the /// order of the polynomial (clamped to range from 2 to 10). Spline(u32, u32) } /// Specifies what sort of palette to use #[derive(Copy, Clone)] pub enum PaletteType { /// Use a gray palette with a specified gamma Gray(f32), /// Use a palette with that uses a predefined formula for each color component. /// Each formula is identified by an integer between [-36, 36]. See gnuplot documentation, or use the pre-defined constants. Formula(i32, i32, i32), /// Use a cube helix palette, with a certain start (in radians), cycles, saturation and gamma. CubeHelix(f32, f32, f32, f32), } /// A gray palette pub const GRAY: PaletteType = Gray(1.0); /// Default Gnuplot palette pub const COLOR: PaletteType = Formula(3, 11, 16); /// Classic rainbow palette with terrible perceptual properties pub const RAINBOW: PaletteType = Formula(33, 13, 10); /// A black body palette pub const HOT: PaletteType = Formula(34, 35, 36); /// A nice default for a cube helix pub const HELIX: PaletteType = CubeHelix(0.5, -0.8, 2.0, 1.0);