@@ -21,7 +21,7 @@ fn read_data<BR: BufRead>(reader: BR) -> HashMap<(String, String), Vec<f64>> {
2121 ds
2222}
2323
24- const OUT_FILE_NAME : & ' static str = "plotters-doc-data/boxplot.svg" ;
24+ const OUT_FILE_NAME : & str = "plotters-doc-data/boxplot.svg" ;
2525fn main ( ) -> Result < ( ) , Box < dyn std:: error:: Error > > {
2626 let root = SVGBackend :: new ( OUT_FILE_NAME , ( 1024 , 768 ) ) . into_drawing_area ( ) ;
2727 root. fill ( & WHITE ) ?;
@@ -40,7 +40,7 @@ fn main() -> Result<(), Box<dyn std::error::Error>> {
4040 } ;
4141 let dataset: Vec < ( String , String , Quartiles ) > = ds
4242 . iter ( )
43- . map ( |( k, v) | ( k. 0 . clone ( ) , k. 1 . clone ( ) , Quartiles :: new ( & v) ) )
43+ . map ( |( k, v) | ( k. 0 . clone ( ) , k. 1 . clone ( ) , Quartiles :: new ( v) ) )
4444 . collect ( ) ;
4545
4646 let host_list: Vec < _ > = dataset
@@ -60,11 +60,7 @@ fn main() -> Result<(), Box<dyn std::error::Error>> {
6060 entry. 0 . push ( ( x. 0 . clone ( ) , & x. 2 ) ) ;
6161 }
6262
63- let values: Vec < f32 > = dataset
64- . iter ( )
65- . map ( |x| x. 2 . values ( ) . to_vec ( ) )
66- . flatten ( )
67- . collect ( ) ;
63+ let values: Vec < f32 > = dataset. iter ( ) . flat_map ( |x| x. 2 . values ( ) . to_vec ( ) ) . collect ( ) ;
6864 let values_range = fitting_range ( values. iter ( ) ) ;
6965
7066 let mut chart = ChartBuilder :: on ( & upper)
@@ -81,13 +77,13 @@ fn main() -> Result<(), Box<dyn std::error::Error>> {
8177 . x_desc ( "Ping, ms" )
8278 . y_desc ( "Host" )
8379 . y_labels ( host_list. len ( ) )
84- . light_line_style ( & WHITE )
80+ . light_line_style ( WHITE )
8581 . draw ( ) ?;
8682
8783 for ( label, ( values, style, offset) ) in & series {
8884 chart
8985 . draw_series ( values. iter ( ) . map ( |x| {
90- Boxplot :: new_horizontal ( SegmentValue :: CenterOf ( & x. 0 ) , & x. 1 )
86+ Boxplot :: new_horizontal ( SegmentValue :: CenterOf ( & x. 0 ) , x. 1 )
9187 . width ( 20 )
9288 . whisker_width ( 0.5 )
9389 . style ( style)
@@ -100,7 +96,7 @@ fn main() -> Result<(), Box<dyn std::error::Error>> {
10096 . configure_series_labels ( )
10197 . position ( SeriesLabelPosition :: UpperRight )
10298 . background_style ( WHITE . filled ( ) )
103- . border_style ( & BLACK . mix ( 0.5 ) )
99+ . border_style ( BLACK . mix ( 0.5 ) )
104100 . legend_area_size ( 22 )
105101 . draw ( ) ?;
106102
@@ -120,7 +116,7 @@ fn main() -> Result<(), Box<dyn std::error::Error>> {
120116 . iter ( )
121117 . chain ( quartiles_b. values ( ) . iter ( ) ) ,
122118 ) ;
123- let mut chart = ChartBuilder :: on ( & left)
119+ let mut chart = ChartBuilder :: on ( left)
124120 . x_label_area_size ( 40 )
125121 . y_label_area_size ( 40 )
126122 . caption ( "Vertical Boxplot" , ( "sans-serif" , 20 ) )
@@ -129,19 +125,19 @@ fn main() -> Result<(), Box<dyn std::error::Error>> {
129125 values_range. start - 10.0 ..values_range. end + 10.0 ,
130126 ) ?;
131127
132- chart. configure_mesh ( ) . light_line_style ( & WHITE ) . draw ( ) ?;
128+ chart. configure_mesh ( ) . light_line_style ( WHITE ) . draw ( ) ?;
133129 chart. draw_series ( vec ! [
134130 Boxplot :: new_vertical( SegmentValue :: CenterOf ( & "a" ) , & quartiles_a) ,
135131 Boxplot :: new_vertical( SegmentValue :: CenterOf ( & "b" ) , & quartiles_b) ,
136132 ] ) ?;
137133
138- let mut chart = ChartBuilder :: on ( & right)
134+ let mut chart = ChartBuilder :: on ( right)
139135 . x_label_area_size ( 40 )
140136 . y_label_area_size ( 40 )
141137 . caption ( "Horizontal Boxplot" , ( "sans-serif" , 20 ) )
142138 . build_cartesian_2d ( -30f32 ..90f32 , 0 ..3 ) ?;
143139
144- chart. configure_mesh ( ) . light_line_style ( & WHITE ) . draw ( ) ?;
140+ chart. configure_mesh ( ) . light_line_style ( WHITE ) . draw ( ) ?;
145141 chart. draw_series ( vec ! [
146142 Boxplot :: new_horizontal( 1 , & quartiles_a) ,
147143 Boxplot :: new_horizontal( 2 , & Quartiles :: new( & [ 30 ] ) ) ,
0 commit comments