XPlot


Plotly Histograms

Binder

Basic Histogram

open XPlot.Plotly
open MathNet.Numerics.Distributions

let normal = Normal(0., 1.0)

let basicX =
    normal.Samples()
    |> Seq.take 500
    |> Seq.toArray

let horizontalY =
    normal.Samples()
    |> Seq.take 500
    |> Seq.toArray

let overlaidX0 =
    normal.Samples()
    |> Seq.take 500
    |> Seq.toArray

let overlaidX1 = Array.map (fun x -> x + 1.) overlaidX0

let stackedX0 =
    normal.Samples()
    |> Seq.take 500
    |> Seq.toArray

let stackedX1 = Array.map (fun x -> x + 1.) stackedX0

let coloredX0 =
    normal.Samples()
    |> Seq.take 500
    |> Seq.toArray

let coloredX1 = Array.map (fun x -> x + 1.) coloredX0

let chart1 =
    Histogram(x = basicX)
    |> Chart.Plot
    |> Chart.WithWidth 700
    |> Chart.WithHeight 500

Horizontal Histogram

let horizontalLayout = Layout(title = "Horizontal Histogram")

let chart2 =
    Histogram(y = horizontalY)
    |> Chart.Plot
    |> Chart.WithLayout horizontalLayout
    |> Chart.WithWidth 700
    |> Chart.WithHeight 500

Overlaid Histogram

let overlaidTrace1 =
    Histogram(
        x = overlaidX0,
        opacity = 0.75
    )

let overlaidTrace2 =
    Histogram(
        x = overlaidX1,
        opacity = 0.75
    )

let overlaidLayout =
    Layout(
        barmode = "overlay",
        title = "Overlaid Histogram"
    )

let chart3 =
    [overlaidTrace1; overlaidTrace2]
    |> Chart.Plot
    |> Chart.WithLayout overlaidLayout
    |> Chart.WithWidth 700
    |> Chart.WithHeight 500

Stacked Histograms

let stackedTrace1 = Histogram(x = stackedX0)

let stackedTrace2 = Histogram(x = stackedX1)

let stackedLayout =
    Layout(
        barmode = "stack",
        title = "Stacked Histograms"
    )

let chart4 =
    [stackedTrace1; stackedTrace2]
    |> Chart.Plot
    |> Chart.WithLayout stackedLayout
    |> Chart.WithWidth 700
    |> Chart.WithHeight 500

Colored and Styled Histograms

let coloredTrace1 =
    Histogram(
        x = coloredX0,
        histnorm = "count",
        name = "control",
        autobinx = false,
        xbins =
            Xbins(
                start = -3.2,
                ``end`` = 2.8,
                size = 0.2
            ),
        marker =
            Marker(
                color = "fuchsia",
                line =
                    Line(
                        color = "grey",
                        width = 0
                    ),
                opacity = 0.75
            )
    )

let coloredTrace2 =
    Histogram(
        x = coloredX1,
        name = "experimental",
        autobinx = false,
        xbins =
            Xbins(
                start = -1.8,
                ``end`` = 4.2,
                size = 0.2
            ),
        marker = Marker(color = "rgb(255, 217, 102)"),
        opacity = 0.75
    )

let coloredLayout =
    Layout(
        title = "Colored and Styled Histograms",
        xaxis = Xaxis(title = "Value"),
        yaxis = Yaxis(title = "Count"),
        barmode = "overlay",
        bargap = 0.25,
        bargroupgap = 0.3
    )

let chart5 =
    [coloredTrace1; coloredTrace2]
    |> Chart.Plot
    |> Chart.WithLayout coloredLayout
    |> Chart.WithWidth 700
    |> Chart.WithHeight 500
namespace XPlot
namespace XPlot.Plotly
namespace MathNet
namespace MathNet.Numerics
namespace MathNet.Numerics.Distributions
val normal : Normal
Multiple items
type Normal =
  interface IContinuousDistribution
  interface IUnivariateDistribution
  interface IDistribution
  new : unit -> unit + 3 overloads
  member CumulativeDistribution : x: float -> float
  member Density : x: float -> float
  member DensityLn : x: float -> float
  member InverseCumulativeDistribution : p: float -> float
  member Sample : unit -> float + 2 overloads
  member Samples : values: float [] -> unit + 5 overloads
  ...

--------------------
Normal() : Normal
Normal(randomSource: System.Random) : Normal
Normal(mean: float, stddev: float) : Normal
Normal(mean: float, stddev: float, randomSource: System.Random) : Normal
val basicX : float []
Normal.Samples() : System.Collections.Generic.IEnumerable<float>
Normal.Samples(values: float []) : unit
module Seq

from Microsoft.FSharp.Collections
val take : count:int -> source:seq<'T> -> seq<'T>
val toArray : source:seq<'T> -> 'T []
val horizontalY : float []
val overlaidX0 : float []
val overlaidX1 : float []
module Array

from Microsoft.FSharp.Collections
val map : mapping:('T -> 'U) -> array:'T [] -> 'U []
val x : float
val stackedX0 : float []
val stackedX1 : float []
val coloredX0 : float []
val coloredX1 : float []
val chart1 : PlotlyChart
Multiple items
type Histogram =
  inherit Trace
  new : unit -> Histogram
  member ShouldSerializeautobinx : unit -> bool
  member ShouldSerializeautobiny : unit -> bool
  member ShouldSerializedx : unit -> bool
  member ShouldSerializedy : unit -> bool
  member ShouldSerializeerror_x : unit -> bool
  member ShouldSerializeerror_y : unit -> bool
  member ShouldSerializehistfunc : unit -> bool
  member ShouldSerializehistnorm : unit -> bool
  ...

--------------------
new : unit -> Histogram
property Histogram.x: obj with get, set
type Chart =
  static member Area : data:seq<#value> -> PlotlyChart + 2 overloads
  static member Bar : data:seq<#value> -> PlotlyChart + 2 overloads
  static member Bubble : data:seq<#key * #value * #value> -> PlotlyChart
  static member Candlestick : data:seq<#key * #value * #value * #value * #value> -> PlotlyChart
  static member Column : data:seq<#value> -> PlotlyChart + 2 overloads
  static member Line : data:seq<#value> -> PlotlyChart + 2 overloads
  static member Pie : data:seq<#key * #value> -> PlotlyChart
  static member Plot : data:Trace -> PlotlyChart + 3 overloads
  static member Scatter : data:seq<#value> -> PlotlyChart + 2 overloads
  static member Show : chart:PlotlyChart -> unit
  ...
static member Chart.Plot : data:seq<#Trace> -> PlotlyChart
static member Chart.Plot : data:Trace -> PlotlyChart
static member Chart.Plot : data:seq<#Trace> * layout:Layout -> PlotlyChart
static member Chart.Plot : data:Trace * layout:Layout -> PlotlyChart
static member Chart.WithWidth : width:int -> chart:PlotlyChart -> PlotlyChart
static member Chart.WithHeight : height:int -> chart:PlotlyChart -> PlotlyChart
member PlotlyChart.GetHtml : unit -> string
val horizontalLayout : Layout
Multiple items
module Layout

from XPlot.Plotly

--------------------
type Layout =
  new : unit -> Layout
  member ShouldSerializeangularaxis : unit -> bool
  member ShouldSerializeannotations : unit -> bool
  member ShouldSerializeautosize : unit -> bool
  member ShouldSerializebargap : unit -> bool
  member ShouldSerializebargroupgap : unit -> bool
  member ShouldSerializebarmode : unit -> bool
  member ShouldSerializeboxmode : unit -> bool
  member ShouldSerializedirection : unit -> bool
  member ShouldSerializedragmode : unit -> bool
  ...

--------------------
new : unit -> Layout
val chart2 : PlotlyChart
property Histogram.y: obj with get, set
static member Chart.WithLayout : layout:Layout -> chart:PlotlyChart -> PlotlyChart
val overlaidTrace1 : Histogram
val overlaidTrace2 : Histogram
val overlaidLayout : Layout
val chart3 : PlotlyChart
val stackedTrace1 : Histogram
val stackedTrace2 : Histogram
val stackedLayout : Layout
val chart4 : PlotlyChart
val coloredTrace1 : Histogram
Multiple items
type Xbins =
  new : unit -> Xbins
  member ShouldSerializeend : unit -> bool
  member ShouldSerializesize : unit -> bool
  member ShouldSerializestart : unit -> bool
  member end : float
  member size : obj
  member start : float

--------------------
new : unit -> Xbins
Multiple items
type Marker =
  new : unit -> Marker
  member ShouldSerializeautocolorscale : unit -> bool
  member ShouldSerializecauto : unit -> bool
  member ShouldSerializecmax : unit -> bool
  member ShouldSerializecmin : unit -> bool
  member ShouldSerializecolor : unit -> bool
  member ShouldSerializecolorbar : unit -> bool
  member ShouldSerializecolors : unit -> bool
  member ShouldSerializecolorscale : unit -> bool
  member ShouldSerializecolorsrc : unit -> bool
  ...

--------------------
new : unit -> Marker
Multiple items
type Line =
  new : unit -> Line
  member ShouldSerializeautocolorscale : unit -> bool
  member ShouldSerializecauto : unit -> bool
  member ShouldSerializecmax : unit -> bool
  member ShouldSerializecmin : unit -> bool
  member ShouldSerializecolor : unit -> bool
  member ShouldSerializecolorscale : unit -> bool
  member ShouldSerializecolorsrc : unit -> bool
  member ShouldSerializedash : unit -> bool
  member ShouldSerializeoutliercolor : unit -> bool
  ...

--------------------
new : unit -> Line
val coloredTrace2 : Histogram
val coloredLayout : Layout
Multiple items
type Xaxis =
  new : unit -> Xaxis
  member ShouldSerialize_isSubplotObj : unit -> bool
  member ShouldSerializeanchor : unit -> bool
  member ShouldSerializeautorange : unit -> bool
  member ShouldSerializeautotick : unit -> bool
  member ShouldSerializebackgroundcolor : unit -> bool
  member ShouldSerializedomain : unit -> bool
  member ShouldSerializedtick : unit -> bool
  member ShouldSerializeexponentformat : unit -> bool
  member ShouldSerializefixedrange : unit -> bool
  ...

--------------------
new : unit -> Xaxis
Multiple items
type Yaxis =
  new : unit -> Yaxis
  member ShouldSerialize_isSubplotObj : unit -> bool
  member ShouldSerializeanchor : unit -> bool
  member ShouldSerializeautorange : unit -> bool
  member ShouldSerializeautotick : unit -> bool
  member ShouldSerializebackgroundcolor : unit -> bool
  member ShouldSerializedomain : unit -> bool
  member ShouldSerializedtick : unit -> bool
  member ShouldSerializeexponentformat : unit -> bool
  member ShouldSerializefixedrange : unit -> bool
  ...

--------------------
new : unit -> Yaxis
val chart5 : PlotlyChart