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

Parallel coordinates

BinderScriptNotebook

Summary: This example shows how to create parallel coordinates plot in F#.

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

In [3]:
open Plotly.NET 

let data = 
    [
        "A",[1.;4.;3.4;0.7;]
        "B",[3.;1.5;1.7;2.3;]
        "C",[2.;4.;3.1;5.]
        "D",[4.;2.;2.;4.;]
    ]

Parallel coordinates are a common way of visualizing high-dimensional geometry and analyzing multivariate data. To show a set of points in an n-dimensional space, a backdrop is drawn consisting of n parallel lines, typically vertical and equally spaced. A point in n-dimensional space is represented as a polyline with vertices on the parallel axes; the position of the vertex on the i-th axis corresponds to the i-th coordinate of the point.

In [4]:
let parcoords1 =
    Chart.ParallelCoord(data,LineColor=Color.fromString "blue", UseDefaults = false)
In [ ]:
parcoords1
Out[ ]:

More styled example

This example shows the usage of some of the styling possibility using Chart.ParallelCoord. For even more styling control, use the respective TraceStyle function TraceDomainStyle.ParallelCoord

In [6]:
open Plotly.NET.TraceObjects

#r "nuget: FSharp.Data"
#r "nuget: Deedle"

open FSharp.Data
open Deedle

let parcoordsStyled =

    let data =
        "https://raw.githubusercontent.com/bcdunbar/datasets/master/iris.csv"
        |> Http.RequestString
        |> Frame.ReadCsvString

    let dims = 
        [
            Dimension.initParallel(Label = "sepal_length", Values = (data |> Frame.getCol "sepal_length" |> Series.values), Range = StyleParam.Range.MinMax(0., 8.))
            Dimension.initParallel(Label = "sepal_width" , Values = (data |> Frame.getCol "sepal_width"  |> Series.values), Range = StyleParam.Range.MinMax(0., 8.))
            Dimension.initParallel(Label = "petal_length", Values = (data |> Frame.getCol "petal_length" |> Series.values), Range = StyleParam.Range.MinMax(0., 8.))
            Dimension.initParallel(Label = "petal_width" , Values = (data |> Frame.getCol "petal_width"  |> Series.values), Range = StyleParam.Range.MinMax(0., 8.))
        ]

    let colors = 
        data
        |> Frame.getCol "species_id"
        |> Series.values
        |> Color.fromColorScaleValues

    Chart.ParallelCoord(
        dims,
        LineColorScale = StyleParam.Colorscale.Viridis,
        LineColor = colors
    )
In [ ]:
parcoordsStyled
    
Out[ ]: