Parallel coordinates
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:
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.
let parcoords1 =
Chart.ParallelCoord(keyValues = data, LineColor = Color.fromString "blue")
More styled example
This example shows the usage of some of the styling options using Chart.ParallelCoord.
For even more styling control, use the respective TraceStyle function TraceDomainStyle.ParallelCoord
open Plotly.NET.TraceObjects
open Deedle
let parcoordsStyled =
let data =
__SOURCE_DIRECTORY__ + "/../data/iris_cat.csv"
|> Frame.ReadCsv
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(dimensions = dims, LineColorScale = StyleParam.Colorscale.Viridis, LineColor = colors)
<summary> Contains mutable global default values. Changing these values will apply the default values to all consecutive Chart generations. </summary>
type DisplayOptions = inherit DynamicObj new: unit -> DisplayOptions static member addAdditionalHeadTags: additionalHeadTags: XmlNode list -> (DisplayOptions -> DisplayOptions) static member addChartDescription: description: XmlNode list -> (DisplayOptions -> DisplayOptions) static member combine: first: DisplayOptions -> second: DisplayOptions -> DisplayOptions static member getAdditionalHeadTags: displayOpts: DisplayOptions -> XmlNode list static member getChartDescription: displayOpts: DisplayOptions -> XmlNode list static member getDocumentCharset: displayOpts: DisplayOptions -> string static member getDocumentDescription: displayOpts: DisplayOptions -> string static member getDocumentFavicon: displayOpts: DisplayOptions -> XmlNode ...
--------------------
new: unit -> Plotly.NET.DisplayOptions
<summary> Sets how plotly is referenced in the head of html docs. </summary>
static member Chart.ParallelCoord: keyValues: (string * #seq<'b>) seq * ?Name: string * ?LineColor: Color * ?LineColorScale: StyleParam.Colorscale * ?ShowLineColorScale: bool * ?ReverseLineColorScale: bool * ?Line: Line * ?LabelAngle: int * ?LabelFont: Font * ?LabelSide: StyleParam.Side * ?RangeFont: Font * ?TickFont: Font * ?UseDefaults: bool -> GenericChart (requires 'b :> System.IConvertible)
static member Chart.ParallelCoord: dimensions: TraceObjects.Dimension seq * ?Name: string * ?LineColor: Color * ?LineColorScale: StyleParam.Colorscale * ?ShowLineColorScale: bool * ?ReverseLineColorScale: bool * ?Line: Line * ?LabelAngle: int * ?LabelFont: Font * ?LabelSide: StyleParam.Side * ?RangeFont: Font * ?TickFont: Font * ?UseDefaults: bool -> GenericChart
<summary> Plotly color can be a single color, a sequence of colors, or a sequence of numeric values referencing the color of the colorscale obj </summary>
<summary> The central type that gets created by all Chart constructors is GenericChart, which itself represents either a single chart or a multi chart (as a Discriminate Union type). A GenericChart consists of four top level objects: Trace (multiple of those in the case of a MultiChart), Layout, Config, and DisplayOptions. - `Trace` is in principle the representation of a dataset on a chart, including for example the data itself, color and shape of the visualization, etc. - `Layout` is everything of the chart that is not dataset specific - e.g. the shape and style of axes, the chart title, etc. - `Config` is an object that configures high level properties of the chart like making all chart elements editable or the tool bar on top - `DisplayOptions` is an object that contains meta information about how the html document that contains the chart. </summary>
module Frame from Deedle
--------------------
type Frame = static member ReadCsv: location: string * hasHeaders: Nullable<bool> * inferTypes: Nullable<bool> * inferRows: Nullable<int> * schema: string * separators: string * culture: string * maxRows: Nullable<int> * missingValues: string array * preferOptions: bool -> Frame<int,string> + 1 overload static member ReadReader: reader: IDataReader -> Frame<int,string> static member CustomExpanders: Dictionary<Type,Func<obj,(string * Type * obj) seq>> static member NonExpandableInterfaces: ResizeArray<Type> static member NonExpandableTypes: HashSet<Type>
--------------------
type Frame<'TRowKey,'TColumnKey (requires equality and equality)> = interface IDynamicMetaObjectProvider interface INotifyCollectionChanged interface IFrameFormattable interface IFsiFormattable interface IFrame new: rowIndex: IIndex<'TRowKey> * columnIndex: IIndex<'TColumnKey> * data: IVector<IVector> * indexBuilder: IIndexBuilder * vectorBuilder: IVectorBuilder -> Frame<'TRowKey,'TColumnKey> + 1 overload member AddColumn: column: 'TColumnKey * series: 'V seq -> unit + 3 overloads member AggregateRowsBy: groupBy: 'TColumnKey seq * aggBy: 'TColumnKey seq * aggFunc: Func<Series<'TRowKey,'a>,'b> -> Frame<int,'TColumnKey> member Clone: unit -> Frame<'TRowKey,'TColumnKey> member ColumnApply: f: Func<Series<'TRowKey,'T>,ISeries<'TRowKey>> -> Frame<'TRowKey,'TColumnKey> + 1 overload ...
--------------------
new: names: 'TColumnKey seq * columns: ISeries<'TRowKey> seq -> Frame<'TRowKey,'TColumnKey>
new: rowIndex: Indices.IIndex<'TRowKey> * columnIndex: Indices.IIndex<'TColumnKey> * data: IVector<IVector> * indexBuilder: Indices.IIndexBuilder * vectorBuilder: Vectors.IVectorBuilder -> Frame<'TRowKey,'TColumnKey>
static member Frame.ReadCsv: stream: System.IO.Stream * ?hasHeaders: bool * ?inferTypes: bool * ?inferRows: int * ?schema: string * ?separators: string * ?culture: string * ?maxRows: int * ?missingValues: string array * ?preferOptions: bool -> Frame<int,string>
static member Frame.ReadCsv: reader: System.IO.TextReader * ?hasHeaders: bool * ?inferTypes: bool * ?inferRows: int * ?schema: string * ?separators: string * ?culture: string * ?maxRows: int * ?missingValues: string array * ?preferOptions: bool -> Frame<int,string>
static member Frame.ReadCsv: stream: System.IO.Stream * hasHeaders: System.Nullable<bool> * inferTypes: System.Nullable<bool> * inferRows: System.Nullable<int> * schema: string * separators: string * culture: string * maxRows: System.Nullable<int> * missingValues: string array * preferOptions: System.Nullable<bool> -> Frame<int,string>
static member Frame.ReadCsv: location: string * hasHeaders: System.Nullable<bool> * inferTypes: System.Nullable<bool> * inferRows: System.Nullable<int> * schema: string * separators: string * culture: string * maxRows: System.Nullable<int> * missingValues: string array * preferOptions: bool -> Frame<int,string>
static member Frame.ReadCsv: path: string * indexCol: string * ?hasHeaders: bool * ?inferTypes: bool * ?inferRows: int * ?schema: string * ?separators: string * ?culture: string * ?maxRows: int * ?missingValues: string array * ?preferOptions: bool -> Frame<'R,string> (requires equality)
type Dimension = inherit DynamicObj new: unit -> Dimension static member initParallel: ?ConstraintRange: Range * ?Label: #IConvertible * ?MultiSelect: bool * ?Name: string * ?Range: Range * ?TemplateItemName: string * ?TickFormat: TickMode * ?TickText: #IConvertible seq * ?Tickvals: #IConvertible seq * ?Values: #IConvertible seq * ?ValuesEncoded: EncodedTypedArray * ?Visible: bool -> Dimension static member initSplom: ?AxisMatches: bool * ?AxisType: AxisType * ?Label: #IConvertible * ?Name: string * ?TemplateItemName: string * ?Values: #IConvertible seq * ?ValuesEncoded: EncodedTypedArray * ?Visible: bool -> Dimension static member style: ?Label: #IConvertible * ?Name: string * ?TemplateItemName: string * ?Values: #IConvertible seq * ?ValuesEncoded: EncodedTypedArray * ?Visible: bool * ?ConstraintRange: Range * ?MultiSelect: bool * ?Range: Range * ?TickFormat: TickMode * ?TickText: #IConvertible seq * ?Tickvals: #IConvertible seq * ?AxisMatches: bool * ?AxisType: AxisType -> (Dimension -> Dimension)
<summary> Dimensions type inherits from dynamic object </summary>
--------------------
new: unit -> Dimension
module Series from Deedle
--------------------
type Series = static member ofNullables: values: Nullable<'a0> seq -> Series<int,'a0> (requires default constructor and value type and 'a0 :> ValueType) static member ofObservations: observations: ('c * 'd) seq -> Series<'c,'d> (requires equality) static member ofOptionalObservations: observations: ('K * 'a1 option) seq -> Series<'K,'a1> (requires equality) static member ofValues: values: 'a seq -> Series<int,'a>
--------------------
type Series<'K,'V (requires equality)> = interface ISeriesFormattable interface IFsiFormattable interface ISeries<'K> new: index: IIndex<'K> * vector: IVector<'V> * vectorBuilder: IVectorBuilder * indexBuilder: IIndexBuilder -> Series<'K,'V> + 3 overloads member After: lowerExclusive: 'K -> Series<'K,'V> member Aggregate: aggregation: Aggregation<'K> * keySelector: Func<DataSegment<Series<'K,'V>>,'TNewKey> * valueSelector: Func<DataSegment<Series<'K,'V>>,OptionalValue<'R>> -> Series<'TNewKey,'R> (requires equality) + 1 overload member AsyncMaterialize: unit -> Async<Series<'K,'V>> member Before: upperExclusive: 'K -> Series<'K,'V> member Between: lowerInclusive: 'K * upperInclusive: 'K -> Series<'K,'V> member Compare: another: Series<'K,'V> -> Series<'K,Diff<'V>> ...
--------------------
new: pairs: System.Collections.Generic.KeyValuePair<'K,'V> seq -> Series<'K,'V>
new: keys: 'K seq * values: 'V seq -> Series<'K,'V>
new: keys: 'K array * values: 'V array -> Series<'K,'V>
new: index: Indices.IIndex<'K> * vector: IVector<'V> * vectorBuilder: Vectors.IVectorBuilder * indexBuilder: Indices.IIndexBuilder -> Series<'K,'V>
<summary> Defines a Range between min and max value </summary>
static member Chart.ParallelCoord: keyValues: (string * #seq<'b>) seq * ?Name: string * ?LineColor: Color * ?LineColorScale: StyleParam.Colorscale * ?ShowLineColorScale: bool * ?ReverseLineColorScale: bool * ?Line: Line * ?LabelAngle: int * ?LabelFont: Font * ?LabelSide: StyleParam.Side * ?RangeFont: Font * ?TickFont: Font * ?UseDefaults: bool -> GenericChart (requires 'b :> System.IConvertible)
static member Chart.ParallelCoord: dimensions: Dimension seq * ?Name: string * ?LineColor: Color * ?LineColorScale: StyleParam.Colorscale * ?ShowLineColorScale: bool * ?ReverseLineColorScale: bool * ?Line: Line * ?LabelAngle: int * ?LabelFont: Font * ?LabelSide: StyleParam.Side * ?RangeFont: Font * ?TickFont: Font * ?UseDefaults: bool -> GenericChart
<summary> The colorscale must be a collection containing a mapping of a normalized value (between 0.0 and 1.0) to it's color. At minimum, a mapping for the lowest (0.0) and highest (1.0) values are required. </summary>
Plotly.NET