Skip to content

Commit b9ec60b

Browse files
committed
fomat examples
1 parent 8169188 commit b9ec60b

File tree

2 files changed

+9
-10
lines changed

2 files changed

+9
-10
lines changed

plotters/examples/3d-plot2.rs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -36,9 +36,7 @@ fn main() -> Result<(), Box<dyn std::error::Error>> {
3636
(-15..=15).map(|x| x as f64 / 5.0),
3737
pdf,
3838
)
39-
.style_func(&|&v| {
40-
(VulcanoHSL::get_color(v / 5.0)).into()
41-
}),
39+
.style_func(&|&v| (VulcanoHSL::get_color(v / 5.0)).into()),
4240
)?;
4341

4442
root.present()?;

plotters/examples/colormaps.rs

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,12 @@ use plotters::prelude::*;
22

33
const OUT_FILE_NAME: &'static str = "plotters-doc-data/colormaps.png";
44

5-
65
fn main() -> Result<(), Box<dyn std::error::Error>> {
76
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"),
1211
];
1312

1413
let colormaps_hsl: [(Box<dyn ColorMap<HSLColor>>, &str); 2] = [
@@ -25,7 +24,10 @@ fn main() -> Result<(), Box<dyn std::error::Error>> {
2524

2625
let mut chart = ChartBuilder::on(&root)
2726
.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+
)?;
2931

3032
use plotters::style::text_anchor::*;
3133
let centered = Pos::new(HPos::Center, VPos::Center);
@@ -55,7 +57,6 @@ fn main() -> Result<(), Box<dyn std::error::Error>> {
5557
plot_colormaps!(colormaps_rgb);
5658
plot_colormaps!(colormaps_hsl);
5759

58-
5960
// To avoid the IO failure being ignored silently, we manually call the present function
6061
root.present().expect("Unable to write result to file, please make sure 'plotters-doc-data' dir exists under current dir");
6162
println!("Result has been saved to {}", OUT_FILE_NAME);

0 commit comments

Comments
 (0)