Chart 1.3.3 → 1.4
raw patch · 5 files changed
+249/−5 lines, 5 filesdep +vectordep ~lensPVP ok
version bump matches the API change (PVP)
Dependencies added: vector
Dependency ranges changed: lens
API changes (from Hackage documentation)
+ Graphics.Rendering.Chart.Axis.Floating: instance PlotValue Float
+ Graphics.Rendering.Chart.Plot.Histogram: PlotHist :: String -> Int -> [x] -> Bool -> Maybe (x, x) -> Bool -> FillStyle -> LineStyle -> (Double -> Int -> y) -> PlotHist x y
+ Graphics.Rendering.Chart.Plot.Histogram: _plot_hist_bins :: PlotHist x y -> Int
+ Graphics.Rendering.Chart.Plot.Histogram: _plot_hist_drop_lines :: PlotHist x y -> Bool
+ Graphics.Rendering.Chart.Plot.Histogram: _plot_hist_fill_style :: PlotHist x y -> FillStyle
+ Graphics.Rendering.Chart.Plot.Histogram: _plot_hist_line_style :: PlotHist x y -> LineStyle
+ Graphics.Rendering.Chart.Plot.Histogram: _plot_hist_no_zeros :: PlotHist x y -> Bool
+ Graphics.Rendering.Chart.Plot.Histogram: _plot_hist_norm_func :: PlotHist x y -> Double -> Int -> y
+ Graphics.Rendering.Chart.Plot.Histogram: _plot_hist_range :: PlotHist x y -> Maybe (x, x)
+ Graphics.Rendering.Chart.Plot.Histogram: _plot_hist_title :: PlotHist x y -> String
+ Graphics.Rendering.Chart.Plot.Histogram: _plot_hist_values :: PlotHist x y -> [x]
+ Graphics.Rendering.Chart.Plot.Histogram: data PlotHist x y
+ Graphics.Rendering.Chart.Plot.Histogram: defaultFloatPlotHist :: PlotHist x Double
+ Graphics.Rendering.Chart.Plot.Histogram: defaultNormedPlotHist :: PlotHist x Double
+ Graphics.Rendering.Chart.Plot.Histogram: defaultPlotHist :: PlotHist x Int
+ Graphics.Rendering.Chart.Plot.Histogram: histToPlot :: (RealFrac x, Num y, Ord y) => PlotHist x y -> Plot x y
+ Graphics.Rendering.Chart.Plot.Histogram: instance Default (PlotHist x Int)
+ Graphics.Rendering.Chart.Plot.Histogram: plot_hist_bins :: Lens' (PlotHist x_aHpb y_aHpc) Int
+ Graphics.Rendering.Chart.Plot.Histogram: plot_hist_drop_lines :: Lens' (PlotHist x_aHpb y_aHpc) Bool
+ Graphics.Rendering.Chart.Plot.Histogram: plot_hist_fill_style :: Lens' (PlotHist x_aHpb y_aHpc) FillStyle
+ Graphics.Rendering.Chart.Plot.Histogram: plot_hist_line_style :: Lens' (PlotHist x_aHpb y_aHpc) LineStyle
+ Graphics.Rendering.Chart.Plot.Histogram: plot_hist_no_zeros :: Lens' (PlotHist x_aHpb y_aHpc) Bool
+ Graphics.Rendering.Chart.Plot.Histogram: plot_hist_norm_func :: Lens (PlotHist x_aHpb y_aHpc) (PlotHist x_aHpb y_aHBf) (Double -> Int -> y_aHpc) (Double -> Int -> y_aHBf)
+ Graphics.Rendering.Chart.Plot.Histogram: plot_hist_range :: Lens' (PlotHist x_aHpb y_aHpc) (Maybe (x_aHpb, x_aHpb))
+ Graphics.Rendering.Chart.Plot.Histogram: plot_hist_title :: Lens' (PlotHist x_aHpb y_aHpc) String
+ Graphics.Rendering.Chart.Plot.Histogram: plot_hist_values :: Lens' (PlotHist x_aHpb y_aHpc) [x_aHpb]
+ Numeric.Histogram: binBounds :: RealFrac a => a -> a -> Int -> [Range a]
+ Numeric.Histogram: histValues :: RealFrac a => a -> a -> Int -> [a] -> Vector (Range a, Int)
+ Numeric.Histogram: histWeightedValues :: RealFrac a => a -> a -> Int -> [(Double, a)] -> Vector (Range a, Double)
+ Numeric.Histogram: histWithBins :: (Num w, RealFrac a) => Vector (Range a) -> [(w, a)] -> Vector (Range a, w)
+ Numeric.Histogram: type Range a = (a, a)
- Graphics.Rendering.Chart.Axis.Floating: la_labelf :: Lens (LinearAxisParams a_aurF) (LinearAxisParams a_avmF) (a_aurF -> String) (a_avmF -> String)
+ Graphics.Rendering.Chart.Axis.Floating: la_labelf :: Lens (LinearAxisParams a_alyI) (LinearAxisParams a_amu3) (a_alyI -> String) (a_amu3 -> String)
- Graphics.Rendering.Chart.Axis.Floating: la_nLabels :: Lens' (LinearAxisParams a_aurF) Int
+ Graphics.Rendering.Chart.Axis.Floating: la_nLabels :: Lens' (LinearAxisParams a_alyI) Int
- Graphics.Rendering.Chart.Axis.Floating: la_nTicks :: Lens' (LinearAxisParams a_aurF) Int
+ Graphics.Rendering.Chart.Axis.Floating: la_nTicks :: Lens' (LinearAxisParams a_alyI) Int
- Graphics.Rendering.Chart.Axis.Floating: loga_labelf :: Iso (LogAxisParams a_aurE) (LogAxisParams a_avop) (a_aurE -> String) (a_avop -> String)
+ Graphics.Rendering.Chart.Axis.Floating: loga_labelf :: Iso (LogAxisParams a_alyH) (LogAxisParams a_amvK) (a_alyH -> String) (a_amvK -> String)
- Graphics.Rendering.Chart.Axis.Types: axis_grid :: Lens' (AxisData x_aoyt) [x_aoyt]
+ Graphics.Rendering.Chart.Axis.Types: axis_grid :: Lens' (AxisData x_ahX7) [x_ahX7]
- Graphics.Rendering.Chart.Axis.Types: axis_labels :: Lens' (AxisData x_aoyt) [[(x_aoyt, String)]]
+ Graphics.Rendering.Chart.Axis.Types: axis_labels :: Lens' (AxisData x_ahX7) [[(x_ahX7, String)]]
- Graphics.Rendering.Chart.Axis.Types: axis_ticks :: Lens' (AxisData x_aoyt) [(x_aoyt, Double)]
+ Graphics.Rendering.Chart.Axis.Types: axis_ticks :: Lens' (AxisData x_ahX7) [(x_ahX7, Double)]
- Graphics.Rendering.Chart.Axis.Types: axis_tropweiv :: Lens' (AxisData x_aoyt) (Range -> Double -> x_aoyt)
+ Graphics.Rendering.Chart.Axis.Types: axis_tropweiv :: Lens' (AxisData x_ahX7) (Range -> Double -> x_ahX7)
- Graphics.Rendering.Chart.Axis.Types: axis_viewport :: Lens' (AxisData x_aoyt) (Range -> x_aoyt -> Double)
+ Graphics.Rendering.Chart.Axis.Types: axis_viewport :: Lens' (AxisData x_ahX7) (Range -> x_ahX7 -> Double)
- Graphics.Rendering.Chart.Axis.Types: axis_visibility :: Lens' (AxisData x_aoyt) AxisVisibility
+ Graphics.Rendering.Chart.Axis.Types: axis_visibility :: Lens' (AxisData x_ahX7) AxisVisibility
- Graphics.Rendering.Chart.Layout: laxis_generate :: Lens' (LayoutAxis x_a1aAR) (AxisFn x_a1aAR)
+ Graphics.Rendering.Chart.Layout: laxis_generate :: Lens' (LayoutAxis x_aIyh) (AxisFn x_aIyh)
- Graphics.Rendering.Chart.Layout: laxis_override :: Lens' (LayoutAxis x_a1aAR) (AxisData x_a1aAR -> AxisData x_a1aAR)
+ Graphics.Rendering.Chart.Layout: laxis_override :: Lens' (LayoutAxis x_aIyh) (AxisData x_aIyh -> AxisData x_aIyh)
- Graphics.Rendering.Chart.Layout: laxis_reverse :: Lens' (LayoutAxis x_a1aAR) Bool
+ Graphics.Rendering.Chart.Layout: laxis_reverse :: Lens' (LayoutAxis x_aIyh) Bool
- Graphics.Rendering.Chart.Layout: laxis_style :: Lens' (LayoutAxis x_a1aAR) AxisStyle
+ Graphics.Rendering.Chart.Layout: laxis_style :: Lens' (LayoutAxis x_aIyh) AxisStyle
- Graphics.Rendering.Chart.Layout: laxis_title :: Lens' (LayoutAxis x_a1aAR) String
+ Graphics.Rendering.Chart.Layout: laxis_title :: Lens' (LayoutAxis x_aIyh) String
- Graphics.Rendering.Chart.Layout: laxis_title_style :: Lens' (LayoutAxis x_a1aAR) FontStyle
+ Graphics.Rendering.Chart.Layout: laxis_title_style :: Lens' (LayoutAxis x_aIyh) FontStyle
- Graphics.Rendering.Chart.Layout: layout_background :: Lens' (Layout x_a1aAM y_a1aAN) FillStyle
+ Graphics.Rendering.Chart.Layout: layout_background :: Lens' (Layout x_aIyc y_aIyd) FillStyle
- Graphics.Rendering.Chart.Layout: layout_bottom_axis_visibility :: Lens' (Layout x_a1aAM y_a1aAN) AxisVisibility
+ Graphics.Rendering.Chart.Layout: layout_bottom_axis_visibility :: Lens' (Layout x_aIyc y_aIyd) AxisVisibility
- Graphics.Rendering.Chart.Layout: layout_grid_last :: Lens' (Layout x_a1aAM y_a1aAN) Bool
+ Graphics.Rendering.Chart.Layout: layout_grid_last :: Lens' (Layout x_aIyc y_aIyd) Bool
- Graphics.Rendering.Chart.Layout: layout_left_axis_visibility :: Lens' (Layout x_a1aAM y_a1aAN) AxisVisibility
+ Graphics.Rendering.Chart.Layout: layout_left_axis_visibility :: Lens' (Layout x_aIyc y_aIyd) AxisVisibility
- Graphics.Rendering.Chart.Layout: layout_legend :: Lens' (Layout x_a1aAM y_a1aAN) (Maybe LegendStyle)
+ Graphics.Rendering.Chart.Layout: layout_legend :: Lens' (Layout x_aIyc y_aIyd) (Maybe LegendStyle)
- Graphics.Rendering.Chart.Layout: layout_margin :: Lens' (Layout x_a1aAM y_a1aAN) Double
+ Graphics.Rendering.Chart.Layout: layout_margin :: Lens' (Layout x_aIyc y_aIyd) Double
- Graphics.Rendering.Chart.Layout: layout_plot_background :: Lens' (Layout x_a1aAM y_a1aAN) (Maybe FillStyle)
+ Graphics.Rendering.Chart.Layout: layout_plot_background :: Lens' (Layout x_aIyc y_aIyd) (Maybe FillStyle)
- Graphics.Rendering.Chart.Layout: layout_plots :: Lens' (Layout x_a1aAM y_a1aAN) [Plot x_a1aAM y_a1aAN]
+ Graphics.Rendering.Chart.Layout: layout_plots :: Lens' (Layout x_aIyc y_aIyd) [Plot x_aIyc y_aIyd]
- Graphics.Rendering.Chart.Layout: layout_right_axis_visibility :: Lens' (Layout x_a1aAM y_a1aAN) AxisVisibility
+ Graphics.Rendering.Chart.Layout: layout_right_axis_visibility :: Lens' (Layout x_aIyc y_aIyd) AxisVisibility
- Graphics.Rendering.Chart.Layout: layout_title :: Lens' (Layout x_a1aAM y_a1aAN) String
+ Graphics.Rendering.Chart.Layout: layout_title :: Lens' (Layout x_aIyc y_aIyd) String
- Graphics.Rendering.Chart.Layout: layout_title_style :: Lens' (Layout x_a1aAM y_a1aAN) FontStyle
+ Graphics.Rendering.Chart.Layout: layout_title_style :: Lens' (Layout x_aIyc y_aIyd) FontStyle
- Graphics.Rendering.Chart.Layout: layout_top_axis_visibility :: Lens' (Layout x_a1aAM y_a1aAN) AxisVisibility
+ Graphics.Rendering.Chart.Layout: layout_top_axis_visibility :: Lens' (Layout x_aIyc y_aIyd) AxisVisibility
- Graphics.Rendering.Chart.Layout: layout_x_axis :: Lens' (Layout x_a1aAM y_a1aAN) (LayoutAxis x_a1aAM)
+ Graphics.Rendering.Chart.Layout: layout_x_axis :: Lens' (Layout x_aIyc y_aIyd) (LayoutAxis x_aIyc)
- Graphics.Rendering.Chart.Layout: layout_y_axis :: Lens' (Layout x_a1aAM y_a1aAN) (LayoutAxis y_a1aAN)
+ Graphics.Rendering.Chart.Layout: layout_y_axis :: Lens' (Layout x_aIyc y_aIyd) (LayoutAxis y_aIyd)
- Graphics.Rendering.Chart.Layout: layoutlr_background :: Lens' (LayoutLR x_a1ayM y1_a1ayN y2_a1ayO) FillStyle
+ Graphics.Rendering.Chart.Layout: layoutlr_background :: Lens' (LayoutLR x_aIy9 y1_aIya y2_aIyb) FillStyle
- Graphics.Rendering.Chart.Layout: layoutlr_bottom_axis_visibility :: Lens' (LayoutLR x_a1ayM y1_a1ayN y2_a1ayO) AxisVisibility
+ Graphics.Rendering.Chart.Layout: layoutlr_bottom_axis_visibility :: Lens' (LayoutLR x_aIy9 y1_aIya y2_aIyb) AxisVisibility
- Graphics.Rendering.Chart.Layout: layoutlr_grid_last :: Lens' (LayoutLR x_a1ayM y1_a1ayN y2_a1ayO) Bool
+ Graphics.Rendering.Chart.Layout: layoutlr_grid_last :: Lens' (LayoutLR x_aIy9 y1_aIya y2_aIyb) Bool
- Graphics.Rendering.Chart.Layout: layoutlr_left_axis :: Lens' (LayoutLR x_a1ayM y1_a1ayN y2_a1ayO) (LayoutAxis y1_a1ayN)
+ Graphics.Rendering.Chart.Layout: layoutlr_left_axis :: Lens' (LayoutLR x_aIy9 y1_aIya y2_aIyb) (LayoutAxis y1_aIya)
- Graphics.Rendering.Chart.Layout: layoutlr_left_axis_visibility :: Lens' (LayoutLR x_a1ayM y1_a1ayN y2_a1ayO) AxisVisibility
+ Graphics.Rendering.Chart.Layout: layoutlr_left_axis_visibility :: Lens' (LayoutLR x_aIy9 y1_aIya y2_aIyb) AxisVisibility
- Graphics.Rendering.Chart.Layout: layoutlr_legend :: Lens' (LayoutLR x_a1ayM y1_a1ayN y2_a1ayO) (Maybe LegendStyle)
+ Graphics.Rendering.Chart.Layout: layoutlr_legend :: Lens' (LayoutLR x_aIy9 y1_aIya y2_aIyb) (Maybe LegendStyle)
- Graphics.Rendering.Chart.Layout: layoutlr_margin :: Lens' (LayoutLR x_a1ayM y1_a1ayN y2_a1ayO) Double
+ Graphics.Rendering.Chart.Layout: layoutlr_margin :: Lens' (LayoutLR x_aIy9 y1_aIya y2_aIyb) Double
- Graphics.Rendering.Chart.Layout: layoutlr_plot_background :: Lens' (LayoutLR x_a1ayM y1_a1ayN y2_a1ayO) (Maybe FillStyle)
+ Graphics.Rendering.Chart.Layout: layoutlr_plot_background :: Lens' (LayoutLR x_aIy9 y1_aIya y2_aIyb) (Maybe FillStyle)
- Graphics.Rendering.Chart.Layout: layoutlr_plots :: Lens' (LayoutLR x_a1ayM y1_a1ayN y2_a1ayO) [Either (Plot x_a1ayM y1_a1ayN) (Plot x_a1ayM y2_a1ayO)]
+ Graphics.Rendering.Chart.Layout: layoutlr_plots :: Lens' (LayoutLR x_aIy9 y1_aIya y2_aIyb) [Either (Plot x_aIy9 y1_aIya) (Plot x_aIy9 y2_aIyb)]
- Graphics.Rendering.Chart.Layout: layoutlr_right_axis :: Lens' (LayoutLR x_a1ayM y1_a1ayN y2_a1ayO) (LayoutAxis y2_a1ayO)
+ Graphics.Rendering.Chart.Layout: layoutlr_right_axis :: Lens' (LayoutLR x_aIy9 y1_aIya y2_aIyb) (LayoutAxis y2_aIyb)
- Graphics.Rendering.Chart.Layout: layoutlr_right_axis_visibility :: Lens' (LayoutLR x_a1ayM y1_a1ayN y2_a1ayO) AxisVisibility
+ Graphics.Rendering.Chart.Layout: layoutlr_right_axis_visibility :: Lens' (LayoutLR x_aIy9 y1_aIya y2_aIyb) AxisVisibility
- Graphics.Rendering.Chart.Layout: layoutlr_title :: Lens' (LayoutLR x_a1ayM y1_a1ayN y2_a1ayO) String
+ Graphics.Rendering.Chart.Layout: layoutlr_title :: Lens' (LayoutLR x_aIy9 y1_aIya y2_aIyb) String
- Graphics.Rendering.Chart.Layout: layoutlr_title_style :: Lens' (LayoutLR x_a1ayM y1_a1ayN y2_a1ayO) FontStyle
+ Graphics.Rendering.Chart.Layout: layoutlr_title_style :: Lens' (LayoutLR x_aIy9 y1_aIya y2_aIyb) FontStyle
- Graphics.Rendering.Chart.Layout: layoutlr_top_axis_visibility :: Lens' (LayoutLR x_a1ayM y1_a1ayN y2_a1ayO) AxisVisibility
+ Graphics.Rendering.Chart.Layout: layoutlr_top_axis_visibility :: Lens' (LayoutLR x_aIy9 y1_aIya y2_aIyb) AxisVisibility
- Graphics.Rendering.Chart.Layout: layoutlr_x_axis :: Lens' (LayoutLR x_a1ayM y1_a1ayN y2_a1ayO) (LayoutAxis x_a1ayM)
+ Graphics.Rendering.Chart.Layout: layoutlr_x_axis :: Lens' (LayoutLR x_aIy9 y1_aIya y2_aIyb) (LayoutAxis x_aIy9)
- Graphics.Rendering.Chart.Layout: slayouts_compress_legend :: Lens' (StackedLayouts x_a1ayH) Bool
+ Graphics.Rendering.Chart.Layout: slayouts_compress_legend :: Lens' (StackedLayouts x_aIy4) Bool
- Graphics.Rendering.Chart.Layout: slayouts_layouts :: Lens (StackedLayouts x_a1ayH) (StackedLayouts x_a1c2S) [StackedLayout x_a1ayH] [StackedLayout x_a1c2S]
+ Graphics.Rendering.Chart.Layout: slayouts_layouts :: Lens (StackedLayouts x_aIy4) (StackedLayouts x_aJZn) [StackedLayout x_aIy4] [StackedLayout x_aJZn]
- Graphics.Rendering.Chart.Plot.Annotation: plot_annotation_angle :: Lens' (PlotAnnotation x_a13zA y_a13zB) Double
+ Graphics.Rendering.Chart.Plot.Annotation: plot_annotation_angle :: Lens' (PlotAnnotation x_aE3W y_aE3X) Double
- Graphics.Rendering.Chart.Plot.Annotation: plot_annotation_hanchor :: Lens' (PlotAnnotation x_a13zA y_a13zB) HTextAnchor
+ Graphics.Rendering.Chart.Plot.Annotation: plot_annotation_hanchor :: Lens' (PlotAnnotation x_aE3W y_aE3X) HTextAnchor
- Graphics.Rendering.Chart.Plot.Annotation: plot_annotation_style :: Lens' (PlotAnnotation x_a13zA y_a13zB) FontStyle
+ Graphics.Rendering.Chart.Plot.Annotation: plot_annotation_style :: Lens' (PlotAnnotation x_aE3W y_aE3X) FontStyle
- Graphics.Rendering.Chart.Plot.Annotation: plot_annotation_values :: Lens (PlotAnnotation x_a13zA y_a13zB) (PlotAnnotation x_a13CE y_a13CF) [(x_a13zA, y_a13zB, String)] [(x_a13CE, y_a13CF, String)]
+ Graphics.Rendering.Chart.Plot.Annotation: plot_annotation_values :: Lens (PlotAnnotation x_aE3W y_aE3X) (PlotAnnotation x_aE70 y_aE71) [(x_aE3W, y_aE3X, String)] [(x_aE70, y_aE71, String)]
- Graphics.Rendering.Chart.Plot.Annotation: plot_annotation_vanchor :: Lens' (PlotAnnotation x_a13zA y_a13zB) VTextAnchor
+ Graphics.Rendering.Chart.Plot.Annotation: plot_annotation_vanchor :: Lens' (PlotAnnotation x_aE3W y_aE3X) VTextAnchor
- Graphics.Rendering.Chart.Plot.AreaSpots: area_spots_4d_linethick :: Lens' (AreaSpots4D z_a14hZ t_a14i0 x_a14i1 y_a14i2) Double
+ Graphics.Rendering.Chart.Plot.AreaSpots: area_spots_4d_linethick :: Lens' (AreaSpots4D z_aEo7 t_aEo8 x_aEo9 y_aEoa) Double
- Graphics.Rendering.Chart.Plot.AreaSpots: area_spots_4d_max_radius :: Lens' (AreaSpots4D z_a14hZ t_a14i0 x_a14i1 y_a14i2) Double
+ Graphics.Rendering.Chart.Plot.AreaSpots: area_spots_4d_max_radius :: Lens' (AreaSpots4D z_aEo7 t_aEo8 x_aEo9 y_aEoa) Double
- Graphics.Rendering.Chart.Plot.AreaSpots: area_spots_4d_opacity :: Lens' (AreaSpots4D z_a14hZ t_a14i0 x_a14i1 y_a14i2) Double
+ Graphics.Rendering.Chart.Plot.AreaSpots: area_spots_4d_opacity :: Lens' (AreaSpots4D z_aEo7 t_aEo8 x_aEo9 y_aEoa) Double
- Graphics.Rendering.Chart.Plot.AreaSpots: area_spots_4d_palette :: Lens' (AreaSpots4D z_a14hZ t_a14i0 x_a14i1 y_a14i2) [Colour Double]
+ Graphics.Rendering.Chart.Plot.AreaSpots: area_spots_4d_palette :: Lens' (AreaSpots4D z_aEo7 t_aEo8 x_aEo9 y_aEoa) [Colour Double]
- Graphics.Rendering.Chart.Plot.AreaSpots: area_spots_4d_title :: Lens' (AreaSpots4D z_a14hZ t_a14i0 x_a14i1 y_a14i2) String
+ Graphics.Rendering.Chart.Plot.AreaSpots: area_spots_4d_title :: Lens' (AreaSpots4D z_aEo7 t_aEo8 x_aEo9 y_aEoa) String
- Graphics.Rendering.Chart.Plot.AreaSpots: area_spots_4d_values :: Lens (AreaSpots4D z_a14hZ t_a14i0 x_a14i1 y_a14i2) (AreaSpots4D z_a14L6 t_a14L7 x_a14L8 y_a14L9) [(x_a14i1, y_a14i2, z_a14hZ, t_a14i0)] [(x_a14L8, y_a14L9, z_a14L6, t_a14L7)]
+ Graphics.Rendering.Chart.Plot.AreaSpots: area_spots_4d_values :: Lens (AreaSpots4D z_aEo7 t_aEo8 x_aEo9 y_aEoa) (AreaSpots4D z_aERa t_aERb x_aERc y_aERd) [(x_aEo9, y_aEoa, z_aEo7, t_aEo8)] [(x_aERc, y_aERd, z_aERa, t_aERb)]
- Graphics.Rendering.Chart.Plot.AreaSpots: area_spots_fillcolour :: Lens' (AreaSpots z_a14i3 x_a14i4 y_a14i5) (Colour Double)
+ Graphics.Rendering.Chart.Plot.AreaSpots: area_spots_fillcolour :: Lens' (AreaSpots z_aEob x_aEoc y_aEod) (Colour Double)
- Graphics.Rendering.Chart.Plot.AreaSpots: area_spots_linecolour :: Lens' (AreaSpots z_a14i3 x_a14i4 y_a14i5) (AlphaColour Double)
+ Graphics.Rendering.Chart.Plot.AreaSpots: area_spots_linecolour :: Lens' (AreaSpots z_aEob x_aEoc y_aEod) (AlphaColour Double)
- Graphics.Rendering.Chart.Plot.AreaSpots: area_spots_linethick :: Lens' (AreaSpots z_a14i3 x_a14i4 y_a14i5) Double
+ Graphics.Rendering.Chart.Plot.AreaSpots: area_spots_linethick :: Lens' (AreaSpots z_aEob x_aEoc y_aEod) Double
- Graphics.Rendering.Chart.Plot.AreaSpots: area_spots_max_radius :: Lens' (AreaSpots z_a14i3 x_a14i4 y_a14i5) Double
+ Graphics.Rendering.Chart.Plot.AreaSpots: area_spots_max_radius :: Lens' (AreaSpots z_aEob x_aEoc y_aEod) Double
- Graphics.Rendering.Chart.Plot.AreaSpots: area_spots_opacity :: Lens' (AreaSpots z_a14i3 x_a14i4 y_a14i5) Double
+ Graphics.Rendering.Chart.Plot.AreaSpots: area_spots_opacity :: Lens' (AreaSpots z_aEob x_aEoc y_aEod) Double
- Graphics.Rendering.Chart.Plot.AreaSpots: area_spots_title :: Lens' (AreaSpots z_a14i3 x_a14i4 y_a14i5) String
+ Graphics.Rendering.Chart.Plot.AreaSpots: area_spots_title :: Lens' (AreaSpots z_aEob x_aEoc y_aEod) String
- Graphics.Rendering.Chart.Plot.AreaSpots: area_spots_values :: Lens (AreaSpots z_a14i3 x_a14i4 y_a14i5) (AreaSpots z_a14Fw x_a14Fx y_a14Fy) [(x_a14i4, y_a14i5, z_a14i3)] [(x_a14Fx, y_a14Fy, z_a14Fw)]
+ Graphics.Rendering.Chart.Plot.AreaSpots: area_spots_values :: Lens (AreaSpots z_aEob x_aEoc y_aEod) (AreaSpots z_aELH x_aELI y_aELJ) [(x_aEoc, y_aEod, z_aEob)] [(x_aELI, y_aELJ, z_aELH)]
- Graphics.Rendering.Chart.Plot.Bars: plot_bars_alignment :: Lens' (PlotBars x_a10ro y_a10rp) PlotBarsAlignment
+ Graphics.Rendering.Chart.Plot.Bars: plot_bars_alignment :: Lens' (PlotBars x_aCDI y_aCDJ) PlotBarsAlignment
- Graphics.Rendering.Chart.Plot.Bars: plot_bars_item_styles :: Lens' (PlotBars x_a10ro y_a10rp) [(FillStyle, Maybe LineStyle)]
+ Graphics.Rendering.Chart.Plot.Bars: plot_bars_item_styles :: Lens' (PlotBars x_aCDI y_aCDJ) [(FillStyle, Maybe LineStyle)]
- Graphics.Rendering.Chart.Plot.Bars: plot_bars_reference :: Lens' (PlotBars x_a10ro y_a10rp) y_a10rp
+ Graphics.Rendering.Chart.Plot.Bars: plot_bars_reference :: Lens' (PlotBars x_aCDI y_aCDJ) y_aCDJ
- Graphics.Rendering.Chart.Plot.Bars: plot_bars_singleton_width :: Lens' (PlotBars x_a10ro y_a10rp) Double
+ Graphics.Rendering.Chart.Plot.Bars: plot_bars_singleton_width :: Lens' (PlotBars x_aCDI y_aCDJ) Double
- Graphics.Rendering.Chart.Plot.Bars: plot_bars_spacing :: Lens' (PlotBars x_a10ro y_a10rp) PlotBarsSpacing
+ Graphics.Rendering.Chart.Plot.Bars: plot_bars_spacing :: Lens' (PlotBars x_aCDI y_aCDJ) PlotBarsSpacing
- Graphics.Rendering.Chart.Plot.Bars: plot_bars_style :: Lens' (PlotBars x_a10ro y_a10rp) PlotBarsStyle
+ Graphics.Rendering.Chart.Plot.Bars: plot_bars_style :: Lens' (PlotBars x_aCDI y_aCDJ) PlotBarsStyle
- Graphics.Rendering.Chart.Plot.Bars: plot_bars_titles :: Lens' (PlotBars x_a10ro y_a10rp) [String]
+ Graphics.Rendering.Chart.Plot.Bars: plot_bars_titles :: Lens' (PlotBars x_aCDI y_aCDJ) [String]
- Graphics.Rendering.Chart.Plot.Bars: plot_bars_values :: Lens (PlotBars x_a10ro y_a10rp) (PlotBars x_a10EC y_a10rp) [(x_a10ro, [y_a10rp])] [(x_a10EC, [y_a10rp])]
+ Graphics.Rendering.Chart.Plot.Bars: plot_bars_values :: Lens (PlotBars x_aCDI y_aCDJ) (PlotBars x_aCQW y_aCDJ) [(x_aCDI, [y_aCDJ])] [(x_aCQW, [y_aCDJ])]
- Graphics.Rendering.Chart.Plot.Candle: plot_candle_centre :: Lens' (PlotCandle x_aX6R y_aX6S) Double
+ Graphics.Rendering.Chart.Plot.Candle: plot_candle_centre :: Lens' (PlotCandle x_aBeV y_aBeW) Double
- Graphics.Rendering.Chart.Plot.Candle: plot_candle_fall_fill_style :: Lens' (PlotCandle x_aX6R y_aX6S) FillStyle
+ Graphics.Rendering.Chart.Plot.Candle: plot_candle_fall_fill_style :: Lens' (PlotCandle x_aBeV y_aBeW) FillStyle
- Graphics.Rendering.Chart.Plot.Candle: plot_candle_fill :: Lens' (PlotCandle x_aX6R y_aX6S) Bool
+ Graphics.Rendering.Chart.Plot.Candle: plot_candle_fill :: Lens' (PlotCandle x_aBeV y_aBeW) Bool
- Graphics.Rendering.Chart.Plot.Candle: plot_candle_line_style :: Lens' (PlotCandle x_aX6R y_aX6S) LineStyle
+ Graphics.Rendering.Chart.Plot.Candle: plot_candle_line_style :: Lens' (PlotCandle x_aBeV y_aBeW) LineStyle
- Graphics.Rendering.Chart.Plot.Candle: plot_candle_rise_fill_style :: Lens' (PlotCandle x_aX6R y_aX6S) FillStyle
+ Graphics.Rendering.Chart.Plot.Candle: plot_candle_rise_fill_style :: Lens' (PlotCandle x_aBeV y_aBeW) FillStyle
- Graphics.Rendering.Chart.Plot.Candle: plot_candle_tick_length :: Lens' (PlotCandle x_aX6R y_aX6S) Double
+ Graphics.Rendering.Chart.Plot.Candle: plot_candle_tick_length :: Lens' (PlotCandle x_aBeV y_aBeW) Double
- Graphics.Rendering.Chart.Plot.Candle: plot_candle_title :: Lens' (PlotCandle x_aX6R y_aX6S) String
+ Graphics.Rendering.Chart.Plot.Candle: plot_candle_title :: Lens' (PlotCandle x_aBeV y_aBeW) String
- Graphics.Rendering.Chart.Plot.Candle: plot_candle_values :: Lens (PlotCandle x_aX6R y_aX6S) (PlotCandle x_aXhC y_aXhD) [Candle x_aX6R y_aX6S] [Candle x_aXhC y_aXhD]
+ Graphics.Rendering.Chart.Plot.Candle: plot_candle_values :: Lens (PlotCandle x_aBeV y_aBeW) (PlotCandle x_aBpG y_aBpH) [Candle x_aBeV y_aBeW] [Candle x_aBpG y_aBpH]
- Graphics.Rendering.Chart.Plot.Candle: plot_candle_width :: Lens' (PlotCandle x_aX6R y_aX6S) Double
+ Graphics.Rendering.Chart.Plot.Candle: plot_candle_width :: Lens' (PlotCandle x_aBeV y_aBeW) Double
- Graphics.Rendering.Chart.Plot.ErrBars: plot_errbars_line_style :: Lens' (PlotErrBars x_aUPd y_aUPe) LineStyle
+ Graphics.Rendering.Chart.Plot.ErrBars: plot_errbars_line_style :: Lens' (PlotErrBars x_aA6T y_aA6U) LineStyle
- Graphics.Rendering.Chart.Plot.ErrBars: plot_errbars_overhang :: Lens' (PlotErrBars x_aUPd y_aUPe) Double
+ Graphics.Rendering.Chart.Plot.ErrBars: plot_errbars_overhang :: Lens' (PlotErrBars x_aA6T y_aA6U) Double
- Graphics.Rendering.Chart.Plot.ErrBars: plot_errbars_tick_length :: Lens' (PlotErrBars x_aUPd y_aUPe) Double
+ Graphics.Rendering.Chart.Plot.ErrBars: plot_errbars_tick_length :: Lens' (PlotErrBars x_aA6T y_aA6U) Double
- Graphics.Rendering.Chart.Plot.ErrBars: plot_errbars_title :: Lens' (PlotErrBars x_aUPd y_aUPe) String
+ Graphics.Rendering.Chart.Plot.ErrBars: plot_errbars_title :: Lens' (PlotErrBars x_aA6T y_aA6U) String
- Graphics.Rendering.Chart.Plot.ErrBars: plot_errbars_values :: Lens (PlotErrBars x_aUPd y_aUPe) (PlotErrBars x_aUZ0 y_aUZ1) [ErrPoint x_aUPd y_aUPe] [ErrPoint x_aUZ0 y_aUZ1]
+ Graphics.Rendering.Chart.Plot.ErrBars: plot_errbars_values :: Lens (PlotErrBars x_aA6T y_aA6U) (PlotErrBars x_aAgG y_aAgH) [ErrPoint x_aA6T y_aA6U] [ErrPoint x_aAgG y_aAgH]
- Graphics.Rendering.Chart.Plot.FillBetween: plot_fillbetween_style :: Lens' (PlotFillBetween x_aU1I y_aU1J) FillStyle
+ Graphics.Rendering.Chart.Plot.FillBetween: plot_fillbetween_style :: Lens' (PlotFillBetween x_azGj y_azGk) FillStyle
- Graphics.Rendering.Chart.Plot.FillBetween: plot_fillbetween_title :: Lens' (PlotFillBetween x_aU1I y_aU1J) String
+ Graphics.Rendering.Chart.Plot.FillBetween: plot_fillbetween_title :: Lens' (PlotFillBetween x_azGj y_azGk) String
- Graphics.Rendering.Chart.Plot.FillBetween: plot_fillbetween_values :: Lens (PlotFillBetween x_aU1I y_aU1J) (PlotFillBetween x_aU5I y_aU5J) [(x_aU1I, (y_aU1J, y_aU1J))] [(x_aU5I, (y_aU5J, y_aU5J))]
+ Graphics.Rendering.Chart.Plot.FillBetween: plot_fillbetween_values :: Lens (PlotFillBetween x_azGj y_azGk) (PlotFillBetween x_azKj y_azKk) [(x_azGj, (y_azGk, y_azGk))] [(x_azKj, (y_azKk, y_azKk))]
- Graphics.Rendering.Chart.Plot.Hidden: plot_hidden_x_values :: Lens (PlotHidden x_aQ0l y_aQ0m) (PlotHidden x_aQ17 y_aQ0m) [x_aQ0l] [x_aQ17]
+ Graphics.Rendering.Chart.Plot.Hidden: plot_hidden_x_values :: Lens (PlotHidden x_axzw y_axzx) (PlotHidden x_axAi y_axzx) [x_axzw] [x_axAi]
- Graphics.Rendering.Chart.Plot.Hidden: plot_hidden_y_values :: Lens (PlotHidden x_aQ0l y_aQ0m) (PlotHidden x_aQ0l y_aQ18) [y_aQ0m] [y_aQ18]
+ Graphics.Rendering.Chart.Plot.Hidden: plot_hidden_y_values :: Lens (PlotHidden x_axzw y_axzx) (PlotHidden x_axzw y_axAj) [y_axzx] [y_axAj]
- Graphics.Rendering.Chart.Plot.Lines: plot_lines_limit_values :: Lens' (PlotLines x_aQcZ y_aQd0) [[(Limit x_aQcZ, Limit y_aQd0)]]
+ Graphics.Rendering.Chart.Plot.Lines: plot_lines_limit_values :: Lens' (PlotLines x_axGm y_axGn) [[(Limit x_axGm, Limit y_axGn)]]
- Graphics.Rendering.Chart.Plot.Lines: plot_lines_style :: Lens' (PlotLines x_aQcZ y_aQd0) LineStyle
+ Graphics.Rendering.Chart.Plot.Lines: plot_lines_style :: Lens' (PlotLines x_axGm y_axGn) LineStyle
- Graphics.Rendering.Chart.Plot.Lines: plot_lines_title :: Lens' (PlotLines x_aQcZ y_aQd0) String
+ Graphics.Rendering.Chart.Plot.Lines: plot_lines_title :: Lens' (PlotLines x_axGm y_axGn) String
- Graphics.Rendering.Chart.Plot.Lines: plot_lines_values :: Lens' (PlotLines x_aQcZ y_aQd0) [[(x_aQcZ, y_aQd0)]]
+ Graphics.Rendering.Chart.Plot.Lines: plot_lines_values :: Lens' (PlotLines x_axGm y_axGn) [[(x_axGm, y_axGn)]]
- Graphics.Rendering.Chart.Plot.Points: plot_points_style :: Lens' (PlotPoints x_aTul y_aTum) PointStyle
+ Graphics.Rendering.Chart.Plot.Points: plot_points_style :: Lens' (PlotPoints x_azoR y_azoS) PointStyle
- Graphics.Rendering.Chart.Plot.Points: plot_points_title :: Lens' (PlotPoints x_aTul y_aTum) String
+ Graphics.Rendering.Chart.Plot.Points: plot_points_title :: Lens' (PlotPoints x_azoR y_azoS) String
- Graphics.Rendering.Chart.Plot.Points: plot_points_values :: Lens (PlotPoints x_aTul y_aTum) (PlotPoints x_aTxl y_aTxm) [(x_aTul, y_aTum)] [(x_aTxl, y_aTxm)]
+ Graphics.Rendering.Chart.Plot.Points: plot_points_values :: Lens (PlotPoints x_azoR y_azoS) (PlotPoints x_azrR y_azrS) [(x_azoR, y_azoS)] [(x_azrR, y_azrS)]
- Graphics.Rendering.Chart.Plot.Types: plot_all_points :: Lens' (Plot x_aPCo y_aPCp) ([x_aPCo], [y_aPCp])
+ Graphics.Rendering.Chart.Plot.Types: plot_all_points :: Lens' (Plot x_axn2 y_axn3) ([x_axn2], [y_axn3])
- Graphics.Rendering.Chart.Plot.Types: plot_legend :: Lens' (Plot x_aPCo y_aPCp) [(String, Rect -> ChartBackend ())]
+ Graphics.Rendering.Chart.Plot.Types: plot_legend :: Lens' (Plot x_axn2 y_axn3) [(String, Rect -> ChartBackend ())]
- Graphics.Rendering.Chart.Plot.Types: plot_render :: Lens' (Plot x_aPCo y_aPCp) (PointMapFn x_aPCo y_aPCp -> ChartBackend ())
+ Graphics.Rendering.Chart.Plot.Types: plot_render :: Lens' (Plot x_axn2 y_axn3) (PointMapFn x_axn2 y_axn3 -> ChartBackend ())
- Graphics.Rendering.Chart.Plot.Vectors: plot_vectors_grid :: Lens' (PlotVectors x_aRbR y_aRbS) [(x_aRbR, y_aRbS)]
+ Graphics.Rendering.Chart.Plot.Vectors: plot_vectors_grid :: Lens' (PlotVectors x_aybf y_aybg) [(x_aybf, y_aybg)]
- Graphics.Rendering.Chart.Plot.Vectors: plot_vectors_mapf :: Lens' (PlotVectors x_aRbR y_aRbS) ((x_aRbR, y_aRbS) -> (x_aRbR, y_aRbS))
+ Graphics.Rendering.Chart.Plot.Vectors: plot_vectors_mapf :: Lens' (PlotVectors x_aybf y_aybg) ((x_aybf, y_aybg) -> (x_aybf, y_aybg))
- Graphics.Rendering.Chart.Plot.Vectors: plot_vectors_scale :: Lens' (PlotVectors x_aRbR y_aRbS) Double
+ Graphics.Rendering.Chart.Plot.Vectors: plot_vectors_scale :: Lens' (PlotVectors x_aybf y_aybg) Double
- Graphics.Rendering.Chart.Plot.Vectors: plot_vectors_style :: Lens' (PlotVectors x_aRbR y_aRbS) VectorStyle
+ Graphics.Rendering.Chart.Plot.Vectors: plot_vectors_style :: Lens' (PlotVectors x_aybf y_aybg) VectorStyle
- Graphics.Rendering.Chart.Plot.Vectors: plot_vectors_title :: Lens' (PlotVectors x_aRbR y_aRbS) String
+ Graphics.Rendering.Chart.Plot.Vectors: plot_vectors_title :: Lens' (PlotVectors x_aybf y_aybg) String
- Graphics.Rendering.Chart.Plot.Vectors: plot_vectors_values :: Lens' (PlotVectors x_aRbR y_aRbS) [((x_aRbR, y_aRbS), (x_aRbR, y_aRbS))]
+ Graphics.Rendering.Chart.Plot.Vectors: plot_vectors_values :: Lens' (PlotVectors x_aybf y_aybg) [((x_aybf, y_aybg), (x_aybf, y_aybg))]
Files
- Chart.cabal +8/−5
- Graphics/Rendering/Chart/Axis/Floating.hs +5/−0
- Graphics/Rendering/Chart/Plot.hs +2/−0
- Graphics/Rendering/Chart/Plot/Histogram.hs +183/−0
- Numeric/Histogram.hs +51/−0
Chart.cabal view
@@ -1,5 +1,5 @@ Name: Chart-Version: 1.3.3+Version: 1.4 License: BSD3 License-file: LICENSE Copyright: Tim Docker, 2006-2014@@ -19,12 +19,14 @@ Build-depends: base >= 3 && < 5 , old-locale , time, mtl, array- , lens >= 3.9 && < 4.8+ , lens >= 3.9 && < 4.10 , colour >= 2.2.1 && < 2.4 , data-default-class < 0.1 , mtl >= 2.0 && < 2.3 , operational >= 0.2.2 && < 0.3+ , vector >=0.9 && <0.11 + Ghc-options: -Wall -fno-warn-orphans Exposed-modules:@@ -55,14 +57,15 @@ Graphics.Rendering.Chart.Plot.Lines, Graphics.Rendering.Chart.Plot.Vectors, Graphics.Rendering.Chart.Plot.Pie,- Graphics.Rendering.Chart.Plot.Points+ Graphics.Rendering.Chart.Plot.Points,+ Graphics.Rendering.Chart.Plot.Histogram Graphics.Rendering.Chart.SparkLine Graphics.Rendering.Chart.Backend Graphics.Rendering.Chart.Backend.Impl Graphics.Rendering.Chart.Backend.Types- Graphics.Rendering.Chart.Easy,+ Graphics.Rendering.Chart.Easy Graphics.Rendering.Chart.State-+ Numeric.Histogram source-repository head type: git location: https://github.com/timbod7/haskell-chart
Graphics/Rendering/Chart/Axis/Floating.hs view
@@ -46,6 +46,11 @@ fromValue= id autoAxis = autoScaledAxis def +instance PlotValue Float where+ toValue = realToFrac+ fromValue= realToFrac+ autoAxis = autoScaledAxis def+ -- | A wrapper class for doubles used to indicate they are to -- be plotted against a percentage axis. newtype Percent = Percent {unPercent :: Double}
Graphics/Rendering/Chart/Plot.hs view
@@ -20,6 +20,7 @@ module Graphics.Rendering.Chart.Plot.Annotation, module Graphics.Rendering.Chart.Plot.AreaSpots, module Graphics.Rendering.Chart.Plot.Pie,+ module Graphics.Rendering.Chart.Plot.Histogram, ) where import Graphics.Rendering.Chart.Plot.Types@@ -34,3 +35,4 @@ import Graphics.Rendering.Chart.Plot.Annotation import Graphics.Rendering.Chart.Plot.AreaSpots import Graphics.Rendering.Chart.Plot.Pie+import Graphics.Rendering.Chart.Plot.Histogram
+ Graphics/Rendering/Chart/Plot/Histogram.hs view
@@ -0,0 +1,183 @@+{-# LANGUAGE TemplateHaskell, FlexibleInstances #-}++module Graphics.Rendering.Chart.Plot.Histogram+ ( -- * Histograms+ PlotHist (..)+ , histToPlot+ , defaultPlotHist+ , defaultFloatPlotHist+ , defaultNormedPlotHist+ -- * Accessors+ , plot_hist_title+ , plot_hist_bins+ , plot_hist_values+ , plot_hist_no_zeros+ , plot_hist_range+ , plot_hist_drop_lines+ , plot_hist_line_style+ , plot_hist_fill_style+ , plot_hist_norm_func+ ) where++import Control.Monad (when)+import Data.Monoid+import Data.Maybe (fromMaybe)+import qualified Data.Foldable as F+import qualified Data.Vector as V++import Control.Lens+import Graphics.Rendering.Chart.Plot.Types+import Graphics.Rendering.Chart.Geometry+import Graphics.Rendering.Chart.Drawing+import Data.Default.Class++import Data.Colour (opaque)+import Data.Colour.Names (blue)+import Data.Colour.SRGB (sRGB)++import Numeric.Histogram++data PlotHist x y = PlotHist+ { -- | Plot title+ _plot_hist_title :: String++ -- | Number of bins+ , _plot_hist_bins :: Int++ -- | Values to histogram+ , _plot_hist_values :: [x]++ -- | Don't attempt to plot bins with zero counts. Useful when+ -- the y-axis is logarithmically scaled.+ , _plot_hist_no_zeros :: Bool++ -- | Override the range of the histogram. If @Nothing@ the+ -- range of @_plot_hist_values@ is used.+ -- + -- Note that any normalization is always computed over the full+ -- data set, including samples not falling in the histogram range.+ , _plot_hist_range :: Maybe (x,x)++ -- | Plot vertical lines between bins+ , _plot_hist_drop_lines :: Bool++ -- | Fill style of the bins+ , _plot_hist_fill_style :: FillStyle++ -- | Line style of the bin outlines+ , _plot_hist_line_style :: LineStyle++ -- | Normalization function+ , _plot_hist_norm_func :: Double -> Int -> y+ }++instance Default (PlotHist x Int) where+ def = defaultPlotHist++-- | The default style is an unnormalized histogram of 20 bins.+defaultPlotHist :: PlotHist x Int+defaultPlotHist = PlotHist { _plot_hist_bins = 20+ , _plot_hist_title = ""+ , _plot_hist_values = []+ , _plot_hist_no_zeros = False+ , _plot_hist_range = Nothing+ , _plot_hist_drop_lines = False+ , _plot_hist_line_style = defaultLineStyle+ , _plot_hist_fill_style = defaultFillStyle+ , _plot_hist_norm_func = const id+ }++-- | @defaultPlotHist@ but with real counts+defaultFloatPlotHist :: PlotHist x Double+defaultFloatPlotHist = defaultPlotHist { _plot_hist_norm_func = const realToFrac }++-- | @defaultPlotHist@ but normalized such that the integral of the+-- histogram is one.+defaultNormedPlotHist :: PlotHist x Double+defaultNormedPlotHist = defaultPlotHist { _plot_hist_norm_func = \n y->realToFrac y / n }++defaultFillStyle :: FillStyle+defaultFillStyle = solidFillStyle (opaque $ sRGB 0.5 0.5 1.0)++defaultLineStyle :: LineStyle+defaultLineStyle = (solidLine 1 $ opaque blue)+ { _line_cap = LineCapButt+ , _line_join = LineJoinMiter+ }++-- | Convert a @PlotHist@ to a @Plot@+--+-- N.B. In principle this should be Chart's @ToPlot@ class but unfortunately+-- this does not allow us to set bounds on the x and y axis types, hence+-- the need for this function.+histToPlot :: (RealFrac x, Num y, Ord y) => PlotHist x y -> Plot x y+histToPlot p = Plot {+ _plot_render = renderPlotHist p,+ _plot_legend = [(_plot_hist_title p, renderPlotLegendHist p)],+ _plot_all_points = unzip+ $ concatMap (\((x1,x2), y)->[(x1,y), (x2,y)])+ $ histToBins p+ }++buildHistPath :: (RealFrac x, Num y)+ => PointMapFn x y -> [((x,x), y)] -> Path+buildHistPath _ [] = End+buildHistPath pmap bins = MoveTo (pt xb 0) (go bins)+ where go [((x1,x2),y)] = LineTo (pt x1 y)+ $ LineTo (pt x2 y)+ $ LineTo (pt x2 0)+ $ End+ go (((x1,x2),y):rest) = LineTo (pt x1 y)+ $ LineTo (pt x2 y)+ $ go rest+ go [] = End+ ((xb,_),_) = head bins+ pt x y = pmap (LValue x, LValue y)++renderPlotHist :: (RealFrac x, Num y, Ord y)+ => PlotHist x y -> PointMapFn x y -> ChartBackend ()+renderPlotHist p pmap+ | null bins = return ()+ | otherwise = do+ withFillStyle (_plot_hist_fill_style p) $+ alignFillPath (buildHistPath pmap bins) >>= fillPath+ withLineStyle (_plot_hist_line_style p) $ do+ when (_plot_hist_drop_lines p) $+ alignStrokePath dropLinesPath >>= strokePath+ alignStrokePath (buildHistPath pmap bins) >>= strokePath+ where bins = histToBins p+ pt x y = pmap (LValue x, LValue y)+ dropLinesPath = F.foldMap (\((x1,_), y)->moveTo (pt x1 0)+ <> lineTo (pt x1 y)+ ) $ tail bins++renderPlotLegendHist :: PlotHist x y -> Rect -> ChartBackend ()+renderPlotLegendHist p (Rect p1 p2) =+ withLineStyle (_plot_hist_line_style p) $+ let y = (p_y p1 + p_y p2) / 2+ in strokePath $ moveTo' (p_x p1) y <> lineTo' (p_x p2) y++histToBins :: (RealFrac x, Num y, Ord y) => PlotHist x y -> [((x,x), y)]+histToBins hist =+ filter_zeros $ zip bounds $ counts+ where n = _plot_hist_bins hist+ (a,b) = realHistRange hist+ dx = realToFrac (b-a) / realToFrac n+ bounds = binBounds a b n+ values = V.fromList (_plot_hist_values hist)+ filter_zeros | _plot_hist_no_zeros hist = filter (\(_,c)->c > 0)+ | otherwise = id+ norm = dx * realToFrac (V.length values)+ normalize = _plot_hist_norm_func hist norm+ counts = V.toList $ V.map (normalize . snd)+ $ histWithBins (V.fromList bounds) (zip (repeat 1) $ V.toList values)++-- TODO: Determine more aesthetically pleasing range+realHistRange :: (RealFrac x) => PlotHist x y -> (x,x)+realHistRange hist = fromMaybe range $ _plot_hist_range hist+ where values = V.fromList (_plot_hist_values hist)+ range = if V.null values+ then (0,0)+ else (V.minimum values, V.maximum values)++$( makeLenses ''PlotHist )
+ Numeric/Histogram.hs view
@@ -0,0 +1,51 @@+{-# LANGUAGE PatternGuards #-} ++module Numeric.Histogram ( Range+ , binBounds+ , histValues+ , histWeightedValues+ , histWithBins+ ) where++import qualified Data.Vector as V+import qualified Data.Vector.Mutable as MV+import Control.Monad.ST++type Range a = (a,a)++-- | 'binBounds a b n' generates bounds for 'n' bins spaced linearly between+-- 'a' and 'b'+binBounds :: RealFrac a => a -> a -> Int -> [Range a]+binBounds a b n = map (\i->(lbound i, lbound (i+1))) [0..n]+ where lbound i = a + (b-a) * realToFrac i / realToFrac n++-- | 'histValues a b n vs' returns the bins for the histogram of+-- 'vs' on the range from 'a' to 'b' with 'n' bins+histValues :: RealFrac a => a -> a -> Int -> [a] -> V.Vector (Range a, Int)+histValues a b n = histWithBins (V.fromList $ binBounds a b n) . zip (repeat 1)++-- | 'histValues a b n vs' returns the bins for the weighted histogram of+-- 'vs' on the range from 'a' to 'b' with 'n' bins+histWeightedValues :: RealFrac a => a -> a -> Int -> [(Double,a)] -> V.Vector (Range a, Double)+histWeightedValues a b n = histWithBins (V.fromList $ binBounds a b n)++-- | 'histWithBins bins xs' is the histogram of weighted values 'xs' with 'bins'+histWithBins :: (Num w, RealFrac a) => V.Vector (Range a) -> [(w, a)] -> V.Vector (Range a, w)+histWithBins bins xs =+ let testBin :: RealFrac a => a -> Range a -> Bool+ testBin x (a,b) = x >= a && x < b++ f :: (RealFrac a, Num w)+ => V.Vector (Range a) -> MV.STVector s w -> (w, a)+ -> ST s ()+ f bins1 bs (w,x) =+ case V.dropWhile (not . testBin x . snd) $ V.indexed bins1 of+ v | V.null v -> return ()+ v | (idx,_) <- V.head v -> do+ n <- MV.read bs idx+ MV.write bs idx $! n+w++ counts = runST $ do b <- MV.replicate (V.length bins) 0+ mapM_ (f bins b) xs+ V.freeze b+ in V.zip bins counts