#r "nuget: Plotly.NET, 5.0.0"
#r "nuget: Plotly.NET.Interactive, 5.0.0"
Summary: This example shows how to create ternary charts in F#.
Let's first create some data for the purpose of creating example charts:
open Plotly.NET
// a coordinates
let a = [ 1; 2; 3; 4; 5; 6; 7 ]
// b coordinates
let b = a |> List.rev
//c
let c = [ 2; 2; 2; 2; 2; 2; 2 ]
A Ternary plot is a barycentric plot on three variables which sum to a constant.
It graphically depicts the ratios of the three variables as positions in an equilateral triangle.
It is used in physical chemistry, petrology, mineralogy, metallurgy, and other physical sciences to show the compositions of systems composed of three species. In population genetics, a triangle plot of genotype frequencies is called a de Finetti diagram. In game theory, it is often called a simplex plot.
Ternary plots are tools for analyzing compositional data in the three-dimensional case.
Use Chart.PointTernary
to create a ternary plot that displays points on a ternary coordinate system:
let ternaryPoint = Chart.PointTernary(A = a, B = b, C = c)
ternaryPoint
Use Chart.LineTernary
to create a ternary plot that displays a line connecting input the data on a ternary coordinate system.
As values on ternary plots sum to a constant, you can omit one dimension of the data by providing that sum.
You can also, for example, change the line style using Chart.withLineStyle
:
let lineTernary =
Chart.LineTernary(A = a, B = b, Sum = 10)
|> Chart.withLineStyle (Color = Color.fromString "purple", Dash = StyleParam.DrawingStyle.DashDot)
lineTernary