plots-0.1.0.2: Diagrams based plotting library.

Copyright(C) 2015 Christopher Chalmers
LicenseBSD-style (see the file LICENSE)
MaintainerChristopher Chalmers
Stabilityexperimental
Portabilitynon-portable
Safe HaskellNone
LanguageHaskell2010

Plots.Types.Histogram

Contents

Description

 

Synopsis

Histogram plot

data HistogramPlot n Source #

Simple histogram type supporting uniform bins.

Already computed histograms

computedHistogram Source #

Arguments

:: (MonadState (Axis b V2 n) m, Plotable (HistogramPlot n) b, Foldable f) 
=> n

start of first bin

-> n

width of each bin

-> f n

heights of the bins

-> State (Plot (HistogramPlot n) b) () 
-> m () 

Plot an already computed histogram with equally sized bins.

Histogram options

class HasOrientation a => HasHistogramOptions a where Source #

Minimal complete definition

histogramOptions

Methods

histogramOptions :: Lens' a (HistogramOptions (N a)) Source #

Options for building the histogram from data.

numBins :: Lens' a Int Source #

The number of bins (bars) to use for the histogram. Must be positive.

Default is 10.

binRange :: Lens' a (Maybe (N a, N a)) Source #

The range of data to consider when building the histogram. Any data outside the range is ignored.

Default is Nothing.

normaliseSample :: Lens' a NormalisationMethod Source #

Should the resulting histogram be normalised so the total area is 1.

Default is False.

Normalisation

data NormalisationMethod Source #

The way to normalise the data from a histogram. The default method is count.

count :: NormalisationMethod Source #

The height of each bar is the number of observations. This is the Default method.

Example

probability :: NormalisationMethod Source #

The sum of the heights of the bars is equal to 1.

Example

countDensity :: NormalisationMethod Source #

The height of each bar is n / w where n is the number of observations and w is the total width.

Example

pdf :: NormalisationMethod Source #

The total area of the bars is 1. This gives a probability density function estimate.

Example

cumilative :: NormalisationMethod Source #

The height of each bar is the cumulative number of observations in each bin and all previous bins. The height of the last bar is the total number of observations.

Example

cdf :: NormalisationMethod Source #

Cumulative density function estimate. The height of each bar is equal to the cumulative relative number of observations in the bin and all previous bins. The height of the last bar is 1.

Example

Plotting histograms

histogramPlot Source #

Arguments

:: (MonadState (Axis b V2 n) m, Plotable (HistogramPlot n) b, Foldable f, RealFrac n) 
=> f n

data

-> State (Plot (HistogramOptions n) b) ()

changes to plot options

-> m ()

add plot to axis

Add a HistogramPlot to the AxisState from a data set.

Example

import Plots
histogramAxis :: Axis B V2 Double
histogramAxis = r2Axis &~ do
  histogramPlot sampleData $ do
    key "histogram"
    plotColor .= blue
    areaStyle . _opacity .= 0.5
histogramExample = renderAxis histogramAxis

histogramPlot' Source #

Arguments

:: (MonadState (Axis b V2 n) m, Plotable (HistogramPlot n) b, Foldable f, RealFrac n) 
=> f n

data

-> m ()

add plot to axis

Make a HistogramPlot without changes to the plot options.

histogramPlotOf Source #

Arguments

:: (MonadState (Axis b V2 n) m, Plotable (HistogramPlot n) b, RealFrac n) 
=> Fold s n

fold over the data

-> s

data to fold

-> State (Plot (HistogramOptions n) b) ()

change to the plot

-> m ()

add plot to the Axis

Add a HistogramPlot using a fold over the data.

histogramPlotOf' :: (MonadState (Axis b V2 n) m, Plotable (HistogramPlot n) b, RealFrac n) => Fold s n -> s -> m () Source #

Same as histogramPlotOf without any changes to the plot.

Low level constructors

mkComputedHistogram Source #

Arguments

:: Foldable f 
=> n

start of first bin

-> n

width of each bin

-> f n

heights of the bins

-> HistogramPlot n 

Construct a HistogramPlot from raw histogram data.

mkHistogramPlot :: (Foldable f, RealFrac n) => HistogramOptions n -> f n -> HistogramPlot n Source #

Create a histogram by binning the data using the HistogramOptions.