-
Notifications
You must be signed in to change notification settings - Fork 81
/
08_0_polar_line-scatter-plots.fsx
113 lines (83 loc) · 2.99 KB
/
08_0_polar_line-scatter-plots.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
(**
---
title: Polar line and scatter plots
category: Polar Charts
categoryindex: 8
index: 1
---
*)
(*** hide ***)
(*** condition: prepare ***)
#r "nuget: Newtonsoft.JSON, 13.0.1"
#r "nuget: DynamicObj, 2.0.0"
#r "../src/Plotly.NET/bin/Release/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
(**
# Polar charts
[![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 create polar charts in F#.
let's first create some data for the purpose of creating example charts:
*)
open Plotly.NET
// radial coordinates
let radial = [ 1; 2; 3; 4; 5; 6; 7;]
// angular coordinates
let theta = [0; 45; 90; 135; 200; 320; 184;]
(**
A polar chart is a graphical method of displaying multivariate data in the form of a two-dimensional chart
of three or more quantitative variables represented on axes starting from the same point.
The relative position and angle of the axes is typically uninformative.
In Polar Charts, a series is represented by a closed curve that connects points in the polar coordinate system.
Each data point is determined by the distance from the pole (the radial coordinate) and the angle from the fixed direction (the angular coordinate).
## Polar point charts
use `Chart.PointPolar` to create a polar plot that displays points on a polar coordinate system:
*)
let pointPolar = Chart.PointPolar(radial,theta)
(*** condition: ipynb ***)
#if IPYNB
pointPolar
#endif // IPYNB
(***hide***)
pointPolar |> GenericChart.toChartHTML
(***include-it-raw***)
(**
## Polar line charts
use `Chart.LinePolar` to create a polar plot that displays a line connecting input the data on a polar coordinate system.
You can for example change the line style using `Chart.withLineStyle`
*)
let linePolar =
Chart.LinePolar(radial,theta)
|> Chart.withLineStyle(Color=Color.fromString "purple",Dash=StyleParam.DrawingStyle.DashDot)
(*** condition: ipynb ***)
#if IPYNB
linePolar
#endif // IPYNB
(***hide***)
linePolar |> GenericChart.toChartHTML
(***include-it-raw***)
(**
## Polar Spline charts
use `Chart.SpinePolar` to create a polar plot that displays a smoothed line connecting input the data on a polar coordinate system.
As for all other plots above, You can for example add labels to each datum:
*)
let splinePolar =
Chart.SplinePolar(
radial,
theta,
MultiText=["one";"two";"three";"four";"five";"six";"seven"],
TextPosition=StyleParam.TextPosition.TopCenter,
ShowMarkers=true
)
(*** condition: ipynb ***)
#if IPYNB
splinePolar
#endif // IPYNB
(***hide***)
splinePolar |> GenericChart.toChartHTML
(***include-it-raw***)