/
8_2_styling_polar_layouts.fsx
119 lines (93 loc) · 2.73 KB
/
8_2_styling_polar_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
111
112
113
114
115
116
117
118
119
(**
---
title: Styling polar layouts
category: Polar Charts
categoryindex: 9
index: 3
---
*)
(*** 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 polar 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
let r = [ 1; 2; 3; 4; 5; 6; 7;] |> List.map ((*) 10000)
let r2 = [ 5; 6; 7; 1; 2; 3; 4;] |> List.map ((*) 10000)
let r3 = [ 3; 1; 5; 2; 8; 7; 5;] |> List.map ((*) 10000)
let t = [0; 45; 90; 135; 200; 320; 184;]
(**
Consider this combined polar chart:
*)
let combinedPolar =
[
Chart.PointPolar(r,t,Name="PointPolar")
Chart.LinePolar(r2,t,Name="LinePolar", ShowMarkers = true)
Chart.SplinePolar(r3,t,Name="SplinePolar", ShowMarkers = true)
]
|> Chart.combine
(*** condition: ipynb ***)
#if IPYNB
combinedPolar
#endif // IPYNB
(***hide***)
combinedPolar |> GenericChart.toChartHTML
(***include-it-raw***)
(**
## Styling the polar layout
Use the `Chart.withPolar` function and initialize a Polar layout with the desired looks
*)
open Plotly.NET.LayoutObjects
let styledPolar =
combinedPolar
|> Chart.withPolar(
Polar.init(
Sector= (0., 270.),
Hole=0.1
)
)
(*** condition: ipynb ***)
#if IPYNB
styledPolar
#endif // IPYNB
(***hide***)
styledPolar |> GenericChart.toChartHTML
(***include-it-raw***)
(**
## Styling radial and angular axes
You could pass these axes to `Chart.withPolar`, but for the case where you want to specifically set the angular or radial axis, there are the `Chart.withAngularAxis` and `Chart.withRadialAxis` functions:
*)
let styledPolar2 =
styledPolar
|> Chart.withAngularAxis(
AngularAxis.init(
Color=Color.fromString "darkblue"
)
)
|> Chart.withRadialAxis(
RadialAxis.init(
Title = Title.init("Hi, i am the radial axis"),
Color=Color.fromString "darkblue",
SeparateThousands = true
)
)
(*** condition: ipynb ***)
#if IPYNB
styledPolar2
#endif // IPYNB
(***hide***)
styledPolar2 |> GenericChart.toChartHTML
(***include-it-raw***)