XPlot


Plotly Box Plots

Binder

Basic Box Plot

open System
open XPlot.Plotly

let rnd = Random()

let randn count min max =
    [1 .. count]
    |> List.map (fun _ -> rnd.NextDouble() * (max - min) + min)

let y0 = randn 50 -1.86 1.67
let y1 = randn 50 -1.2 3.44

let trace1 = Box(y = y0)
let trace2 = Box(y = y1)

let chart1 =
    [trace1; trace2]
    |> Chart.Plot
    |> Chart.WithWidth 700
    |> Chart.WithHeight 500

Box Plot That Displays the Underlying Data

let chart2 =
    Box(
        y = [0; 1; 1; 2; 3; 5; 8; 13; 21],
        boxpoints = "all",
        jitter = 0.3,
        pointpos = -1.8
    )
    |> Chart.Plot
    |> Chart.WithWidth 700
    |> Chart.WithHeight 500

Grouped Box Plot

let x = ["day 1"; "day 1"; "day 1"; "day 1"; "day 1"; "day 1";
        "day 2"; "day 2"; "day 2"; "day 2"; "day 2"; "day 2"]

let groupedTrace1 =
    Box(
        y = [0.2; 0.2; 0.6; 1.0; 0.5; 0.4; 0.2; 0.7; 0.9; 0.1; 0.5; 0.3],
        x = x,
        name = "kale",
        marker = Marker(color = "#3D9970")
    )

let groupedTrace2 =
    Box(
        y = [0.6; 0.7; 0.3; 0.6; 0.0; 0.5; 0.7; 0.9; 0.5; 0.8; 0.7; 0.2],
        x = x,
        name = "radishes",
        marker = Marker(color = "#FF4136")
    )

let groupedTrace3 =
    Box(
        y = [0.1; 0.3; 0.1; 0.9; 0.6; 0.6; 0.9; 1.0; 0.3; 0.6; 0.8; 0.5],
        x = x,
        name = "carrots",
        marker = Marker(color = "#FF851B")
    )

let layout =
    Layout(
        yaxis =
            Yaxis(
                title = "normalized moisture",
                zeroline = false
            ),
        boxmode = "group"
    )

let chart3 =
    [groupedTrace1; groupedTrace2; groupedTrace3]
    |> Chart.Plot
    |> Chart.WithLayout layout
    |> Chart.WithWidth 700
    |> Chart.WithHeight 500
namespace System
namespace XPlot
namespace XPlot.Plotly
val rnd : Random
Multiple items
type Random =
  new : unit -> unit + 1 overload
  member Next : unit -> int + 2 overloads
  member NextBytes : buffer: byte [] -> unit + 1 overload
  member NextDouble : unit -> float
  member Sample : unit -> float

--------------------
Random() : Random
Random(Seed: int) : Random
val randn : count:int -> min:float -> max:float -> float list
val count : int
val min : float
val max : float
Multiple items
module List

from Microsoft.FSharp.Collections

--------------------
type List<'T> =
  | ( [] )
  | ( :: ) of Head: 'T * Tail: 'T list
    interface IReadOnlyList<'T>
    interface IReadOnlyCollection<'T>
    interface IEnumerable
    interface IEnumerable<'T>
    member GetReverseIndex : rank:int * offset:int -> int
    member GetSlice : startIndex:int option * endIndex:int option -> 'T list
    static member Cons : head:'T * tail:'T list -> 'T list
    member Head : 'T
    member IsEmpty : bool
    member Item : index:int -> 'T with get
    ...
val map : mapping:('T -> 'U) -> list:'T list -> 'U list
Random.NextDouble() : float
val y0 : float list
val y1 : float list
val trace1 : Box
Multiple items
type Box =
  inherit Trace
  new : unit -> Box
  member ShouldSerializeboxmean : unit -> bool
  member ShouldSerializeboxpoints : unit -> bool
  member ShouldSerializefillcolor : unit -> bool
  member ShouldSerializehoverinfo : unit -> bool
  member ShouldSerializejitter : unit -> bool
  member ShouldSerializelegendgroup : unit -> bool
  member ShouldSerializeline : unit -> bool
  member ShouldSerializemarker : unit -> bool
  ...

--------------------
new : unit -> Box
property Box.y: obj with get, set
val trace2 : Box
val chart1 : PlotlyChart
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 chart2 : PlotlyChart
val x : string list
val groupedTrace1 : Box
property Box.x: obj with get, set
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
val groupedTrace2 : Box
val groupedTrace3 : Box
val layout : 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
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 chart3 : PlotlyChart
static member Chart.WithLayout : layout:Layout -> chart:PlotlyChart -> PlotlyChart