In [ ]:
#r "nuget: Plotly.NET, 2.0.0"
#r "nuget: Plotly.NET.Interactive, 2.0.0"

Range plots

BinderScriptNotebook

Summary: This example shows how to create Range plot charts in F#.

let's first create some data for the purpose of creating example charts:

In [3]:
open Plotly.NET 

let rnd = System.Random()

let x  = [1.; 2.; 3.; 4.; 5.; 6.; 7.; 8.; 9.; 10.; ]
let y = [2.; 1.5; 5.; 1.5; 3.; 2.5; 2.5; 1.5; 3.5; 1.]

let yUpper = y |> List.map (fun v -> v + rnd.NextDouble())
let yLower = y |> List.map (fun v -> v - rnd.NextDouble())

A range plot is commonly used to indicate some property of data that lies in a certain range around a central value, for example the range of all predictions from different models, scattering around a central tendency.

In [4]:
let range1 =
    Chart.Range(
        x,y,yUpper,yLower,
        StyleParam.Mode.Lines_Markers,
        MarkerColor = Color.fromString "grey",
        RangeColor = Color.fromString "lightblue")
In [ ]:
range1
Out[ ]:

More styled example

This example shows the usage of some of the styling possibility using Chart.Range.

In [6]:
open Plotly.NET.TraceObjects

let rangeStyled = 
    Chart.Range(
        x = [1;2;3;4;5],
        y = [2;2;3;4;6],
        upper= [4;6;7;5;7],
        lower= [0;0;0;1;5],
        mode = StyleParam.Mode.Lines_Markers,
        TextPosition = StyleParam.TextPosition.TopCenter,
        RangeColor = Color.fromString "rgba(0, 204, 150, 0.2)",
        LowerLine = Line.init(Width = 2., Color = Color.fromString "rgba(0, 204, 150, 0.4)"),
        LowerMarker = Marker.init(Color = Color.fromString "rgba(0, 204, 150, 0.6)"),
        UpperLine = Line.init(Width = 2., Color = Color.fromString "rgba(0, 204, 150, 0.4)"),
        UpperMarker = Marker.init(Color = Color.fromString "rgba(0, 204, 150, 0.6)"),
        MultiText = ["Mid1"; "Mid2"; "Mid3"; "Mid4"; "Mid5"],
        MultiLowerText = ["Lower1"; "Lower2"; "Lower3"; "Lower4"; "Lower5"],
        MultiUpperText = ["Upper1"; "Upper2"; "Upper3"; "Upper4"; "Upper5"],
        ShowLegend = true
    )
In [ ]:
rangeStyled
Out[ ]: