Skip to content

Histogram

lucymukh edited this page Dec 17, 2018 · 1 revision

Histogram plot is one of the plot types that can be added to the chart.

Histogram creation

To create a histogram plot you need samples DataSeries: float seq to calculate the histogram for.

let histogram = createHistogram DataSeries

Note

Actually the histogram plot is a record of type FSharpIDD.Plots.Histogram.Plot

You can also create it by explicitly filling up all record fields:

{
        /// Specifies how to annotate the histogram in a legend
        Name: string
        /// Samples to calculate the histogram for
        Samples: DataSeries        
        /// The colour of the histogram
        Colour: Colour.Colour
        /// Number of bins in the histogram
        BinCount: int
}

Configuring histogram style

The histogram plot has five appearance options that can be configured:

  • Name (as it's seen in a legend)
  • Colour
  • Number of bins

You can use the following functions of the module FSharpIDD.Plots.Histogram to define the options respectively:

  • setName: name:string -> histogram:Plot -> Plot
  • setColour: colour:Colour.Colour -> histogram:Plot -> Plot
  • setBinCount: bincount:int -> histogram:Plot -> Plot

Example

let histogram1 = 
    createHistogram DataSeries
    |> setName "Histogram 1"
    |> setColour Colour.Crimson
    |> setBinCount 10

There is also an option to set several appearance characteristics with a single setOptions: options:Options -> histogram:Plot -> Plot call.

The convenience of the method is that you can define several (but not necessarily all) options during Options value creation.

Example

let histogramOptions = Options(Name = "Histogram1", Colour = Colour.PapayaWhip, BinCount = 20)
let histogramPlot =
    createHistogram DataSeries
    |> setOptions histogramOptions 
Clone this wiki locally