File tree Expand file tree Collapse file tree 1 file changed +13
-0
lines changed
Expand file tree Collapse file tree 1 file changed +13
-0
lines changed Original file line number Diff line number Diff line change @@ -20,11 +20,15 @@ TODO:
2020 - What should be the default?
2121*/
2222
23+ use axis;
24+
2325#[ derive( Debug ) ]
2426pub struct Histogram {
2527 pub bin_bounds : Vec < f64 > , // will have N_bins + 1 entries
2628 pub bin_counts : Vec < u32 > , // will have N_bins entries
2729 pub bin_densities : Vec < f64 > , // will have N_bins entries
30+ pub x_axis : axis:: Axis ,
31+ pub y_axis : axis:: Axis ,
2832}
2933
3034impl Histogram {
@@ -56,10 +60,19 @@ impl Histogram {
5660 }
5761 let density_per_bin = bins. iter ( ) . map ( |& x| x as f64 / bin_width) . collect ( ) ;
5862
63+ let x_min = * bounds. first ( ) . expect ( "ERROR: There are no ticks for the x-axis" ) ;
64+ let x_max = * bounds. last ( ) . expect ( "ERROR: There are no ticks for the x-axis" ) ;
65+ let x_axis = axis:: Axis :: new ( x_min, x_max) ;
66+
67+ let largest_bin_count = * bins. iter ( ) . max ( ) . expect ( "ERROR: There are no bins" ) ;
68+ let y_axis = axis:: Axis :: new ( 0.0 , largest_bin_count as f64 ) ;
69+
5970 Histogram {
6071 bin_bounds : bounds,
6172 bin_counts : bins,
6273 bin_densities : density_per_bin,
74+ x_axis : x_axis,
75+ y_axis : y_axis,
6376 }
6477 }
6578
You can’t perform that action at this time.
0 commit comments