@@ -2,13 +2,12 @@ use plotters::prelude::*;
2
2
3
3
const OUT_FILE_NAME : & ' static str = "plotters-doc-data/colormaps.png" ;
4
4
5
-
6
5
fn main ( ) -> Result < ( ) , Box < dyn std:: error:: Error > > {
7
6
let colormaps_rgb: [ ( Box < dyn ColorMap < RGBColor > > , & str ) ; 4 ] = [
8
- ( Box :: new ( ViridisRGB { } ) , "Viridis" ) ,
9
- ( Box :: new ( BlackWhite { } ) , "BlackWhite" ) ,
10
- ( Box :: new ( Bone { } ) , "Bone" ) ,
11
- ( Box :: new ( Copper { } ) , "Copper" ) ,
7
+ ( Box :: new ( ViridisRGB { } ) , "Viridis" ) ,
8
+ ( Box :: new ( BlackWhite { } ) , "BlackWhite" ) ,
9
+ ( Box :: new ( Bone { } ) , "Bone" ) ,
10
+ ( Box :: new ( Copper { } ) , "Copper" ) ,
12
11
] ;
13
12
14
13
let colormaps_hsl: [ ( Box < dyn ColorMap < HSLColor > > , & str ) ; 2 ] = [
@@ -25,7 +24,10 @@ fn main() -> Result<(), Box<dyn std::error::Error>> {
25
24
26
25
let mut chart = ChartBuilder :: on ( & root)
27
26
. caption ( "Demonstration of predefined colormaps" , ( "sans-serif" , 20 ) )
28
- . build_cartesian_2d ( -150.0 ..size_x as f32 +50.0 , 0.0 ..3.0 * ( n_colormaps as f32 ) ) ?;
27
+ . build_cartesian_2d (
28
+ -150.0 ..size_x as f32 + 50.0 ,
29
+ 0.0 ..3.0 * ( n_colormaps as f32 ) ,
30
+ ) ?;
29
31
30
32
use plotters:: style:: text_anchor:: * ;
31
33
let centered = Pos :: new ( HPos :: Center , VPos :: Center ) ;
@@ -55,7 +57,6 @@ fn main() -> Result<(), Box<dyn std::error::Error>> {
55
57
plot_colormaps ! ( colormaps_rgb) ;
56
58
plot_colormaps ! ( colormaps_hsl) ;
57
59
58
-
59
60
// To avoid the IO failure being ignored silently, we manually call the present function
60
61
root. present ( ) . expect ( "Unable to write result to file, please make sure 'plotters-doc-data' dir exists under current dir" ) ;
61
62
println ! ( "Result has been saved to {}" , OUT_FILE_NAME ) ;
0 commit comments