plots-0.1.1.4: Diagrams based plotting library
Copyright(C) 2015 Christopher Chalmers
LicenseBSD-style (see the file LICENSE)
MaintainerChristopher Chalmers
Stabilityexperimental
Portabilitynon-portable
Safe HaskellSafe-Inferred
LanguageHaskell2010

Plots.Types.Histogram

Description

 
Synopsis

Histogram plot

data HistogramPlot n Source #

Simple histogram type supporting uniform bins.

Instances

Instances details
OrderedField n => Enveloped (HistogramPlot n) Source # 
Instance details

Defined in Plots.Types.Histogram

HasOrientation (HistogramPlot n) Source # 
Instance details

Defined in Plots.Types.Histogram

(TypeableFloat n, Renderable (Path V2 n) b) => Plotable (HistogramPlot n) b Source # 
Instance details

Defined in Plots.Types.Histogram

Methods

renderPlotable :: forall (v :: Type -> Type) n0. InSpace v n0 (HistogramPlot n) => AxisSpec v n0 -> PlotStyle b v n0 -> HistogramPlot n -> QDiagram b v n0 Any Source #

defLegendPic :: forall (v :: Type -> Type) n0. InSpace v n0 (HistogramPlot n) => PlotStyle b v n0 -> HistogramPlot n -> QDiagram b v n0 Any Source #

type N (HistogramPlot n) Source # 
Instance details

Defined in Plots.Types.Histogram

type N (HistogramPlot n) = n
type V (HistogramPlot n) Source # 
Instance details

Defined in Plots.Types.Histogram

type V (HistogramPlot n) = V2

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

data HistogramOptions n Source #

Options for binning histogram data. For now only very basic histograms building is supported.

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.

Instances

Instances details
Default NormalisationMethod Source # 
Instance details

Defined in Plots.Types.Histogram

count :: NormalisationMethod Source #

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

Example

Expand

probability :: NormalisationMethod Source #

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

Example

Expand

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

Expand

pdf :: NormalisationMethod Source #

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

Example

Expand

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

Expand

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

Expand

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

Expand

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.