-
Notifications
You must be signed in to change notification settings - Fork 81
/
10_1_styling_ternary_layouts.fsx
110 lines (83 loc) · 2.52 KB
/
10_1_styling_ternary_layouts.fsx
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
(**
---
title: Styling ternary layouts
category: Ternary Plots
categoryindex: 11
index: 2
---
*)
(*** hide ***)
(*** condition: prepare ***)
#r "nuget: Newtonsoft.JSON, 12.0.3"
#r "nuget: DynamicObj"
#r "../bin/Plotly.NET/netstandard2.0/Plotly.NET.dll"
(*** condition: ipynb ***)
#if IPYNB
#r "nuget: Plotly.NET, {{fsdocs-package-version}}"
#r "nuget: Plotly.NET.Interactive, {{fsdocs-package-version}}"
#endif // IPYNB
(**
# Styling ternary layouts
[![Binder]({{root}}img/badge-binder.svg)](https://mybinder.org/v2/gh/plotly/Plotly.NET/gh-pages?filepath={{fsdocs-source-basename}}.ipynb) 
[![Script]({{root}}img/badge-script.svg)]({{root}}{{fsdocs-source-basename}}.fsx) 
[![Notebook]({{root}}img/badge-notebook.svg)]({{root}}{{fsdocs-source-basename}}.ipynb)
*Summary:* This example shows how to style polar layouts 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;]
(**
Consider this combined ternary chart:
*)
let combinedTernary =
[
Chart.PointTernary(a,b,c)
Chart.LineTernary(a,c,Sum = 10)
]
|> Chart.combine
(*** condition: ipynb ***)
#if IPYNB
combinedTernary
#endif // IPYNB
(***hide***)
combinedTernary |> GenericChart.toChartHTML
(***include-it-raw***)
(**
## Styling the polar layout
Use the `Chart.withTernary` function and initialize a Ternary layout with the desired looks
*)
open Plotly.NET.LayoutObjects
let styledTernary =
combinedTernary
|> Chart.withTernary(
Ternary.init(
AAxis = LinearAxis.init(Title = Title.init("A"), Color = Color.fromKeyword ColorKeyword.DarkOrchid),
BAxis = LinearAxis.init(Title = Title.init("B"), Color = Color.fromKeyword ColorKeyword.DarkRed)
)
)
(*** condition: ipynb ***)
#if IPYNB
styledTernary
#endif // IPYNB
(***hide***)
styledTernary |> GenericChart.toChartHTML
(***include-it-raw***)
(**
## Styling A, B, and C Axes
You could pass these axes to `Chart.withTernary` as above, but for the case where you want to specifically set one axis, there are the `Chart.withAAxis`, `Chart.withBAxis`, `Chart.withCAxis` functions:
*)
let styledTernary2 =
styledTernary
|> Chart.withCAxis(LinearAxis.init(Title = Title.init("C"), Color = Color.fromKeyword ColorKeyword.DarkCyan))
(*** condition: ipynb ***)
#if IPYNB
styledTernary2
#endif // IPYNB
(***hide***)
styledTernary2 |> GenericChart.toChartHTML
(***include-it-raw***)