Skip to content

Commit 2ef7e17

Browse files
authored
Merge pull request #113 from plotly/polar
Add Polar Charts and full axis support
2 parents a5786d4 + 41da2a7 commit 2ef7e17

32 files changed

+2966
-618
lines changed

Diff for: Plotly.NET.sln

+3-2
Original file line numberDiff line numberDiff line change
@@ -87,8 +87,9 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "content", "content", "{60FB
8787
docs\7_0_candlestick.fsx = docs\7_0_candlestick.fsx
8888
docs\7_1_funnel.fsx = docs\7_1_funnel.fsx
8989
docs\7_2_funnel_area.fsx = docs\7_2_funnel_area.fsx
90-
docs\8_0_polar-charts.fsx = docs\8_0_polar-charts.fsx
91-
docs\8_1_windrose-charts.fsx = docs\8_1_windrose-charts.fsx
90+
docs\8_0_polar_line-scatter-plots.fsx = docs\8_0_polar_line-scatter-plots.fsx
91+
docs\8_1_polar_bar_charts.fsx = docs\8_1_polar_bar_charts.fsx
92+
docs\8_2_styling_polar_layouts.fsx = docs\8_2_styling_polar_layouts.fsx
9293
docs\9_0_parallel-categories.fsx = docs\9_0_parallel-categories.fsx
9394
docs\9_1_parallel-coords.fsx = docs\9_1_parallel-coords.fsx
9495
docs\9_2_sankey.fsx = docs\9_2_sankey.fsx

Diff for: docs/1_0_axis-styling.fsx

+8-8
Original file line numberDiff line numberDiff line change
@@ -64,20 +64,20 @@ The following example creates two mirrored axes with inside ticks, one of them w
6464

6565
let mirroredXAxis =
6666
Axis.LinearAxis.init(
67-
Title ="Log axis",
68-
Showline = true,
67+
Title = Title.init(Text="Mirrored axis"),
68+
ShowLine = true,
6969
Mirror = StyleParam.Mirror.AllTicks,
70-
Showgrid = false,
70+
ShowGrid = false,
7171
Ticks = StyleParam.TickOptions.Inside
7272
)
7373

7474
let mirroredLogYAxis =
7575
Axis.LinearAxis.init(
76-
Title ="Log axis",
76+
Title = Title.init(Text="Log axis"),
7777
AxisType = StyleParam.AxisType.Log,
78-
Showline = true,
78+
ShowLine = true,
7979
Mirror = StyleParam.Mirror.AllTicks,
80-
Showgrid = false,
80+
ShowGrid = false,
8181
Ticks = StyleParam.TickOptions.Inside
8282
)
8383

@@ -159,7 +159,7 @@ let twoXAxes2 =
159159
|> Chart.Combine
160160
|> Chart.withY_AxisStyle(
161161
"first y-axis",
162-
Showline=true
162+
ShowLine=true
163163
)
164164
|> Chart.withX_AxisStyle(
165165
"x-axis",
@@ -172,7 +172,7 @@ let twoXAxes2 =
172172
Overlaying=StyleParam.AxisAnchorId.Y 1,
173173
Position=0.10, // position the axis beteen the leftmost edge and the firt axis at 0.3
174174
Anchor=StyleParam.AxisAnchorId.Free,
175-
Showline=true
175+
ShowLine=true
176176
)
177177

178178
(*** condition: ipynb ***)

Diff for: docs/8_0_polar-charts.fsx

-64
This file was deleted.

Diff for: docs/8_0_polar_line-scatter-plots.fsx

+112
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,112 @@
1+
(**
2+
---
3+
title: Polar line and scatter plots
4+
category: Polar Charts
5+
categoryindex: 8
6+
index: 1
7+
---
8+
*)
9+
10+
(*** hide ***)
11+
12+
(*** condition: prepare ***)
13+
#r "nuget: Newtonsoft.JSON, 12.0.3"
14+
#r "../bin/Plotly.NET/netstandard2.0/Plotly.NET.dll"
15+
16+
(*** condition: ipynb ***)
17+
#if IPYNB
18+
#r "nuget: Plotly.NET, {{fsdocs-package-version}}"
19+
#r "nuget: Plotly.NET.Interactive, {{fsdocs-package-version}}"
20+
#endif // IPYNB
21+
22+
(**
23+
# Polar charts
24+
25+
[![Binder]({{root}}img/badge-binder.svg)](https://mybinder.org/v2/gh/plotly/Plotly.NET/gh-pages?filepath={{fsdocs-source-basename}}.ipynb) 
26+
[![Script]({{root}}img/badge-script.svg)]({{root}}{{fsdocs-source-basename}}.fsx) 
27+
[![Notebook]({{root}}img/badge-notebook.svg)]({{root}}{{fsdocs-source-basename}}.ipynb)
28+
29+
*Summary:* This example shows how to create polar charts in F#.
30+
31+
let's first create some data for the purpose of creating example charts:
32+
33+
*)
34+
35+
open Plotly.NET
36+
37+
// radial coordinates
38+
let radial = [ 1; 2; 3; 4; 5; 6; 7;]
39+
40+
// angular coordinates
41+
let theta = [0; 45; 90; 135; 200; 320; 184;]
42+
43+
(**
44+
A polar chart is a graphical method of displaying multivariate data in the form of a two-dimensional chart
45+
of three or more quantitative variables represented on axes starting from the same point.
46+
47+
The relative position and angle of the axes is typically uninformative.
48+
49+
In Polar Charts, a series is represented by a closed curve that connects points in the polar coordinate system.
50+
Each data point is determined by the distance from the pole (the radial coordinate) and the angle from the fixed direction (the angular coordinate).
51+
52+
## Polar point charts
53+
54+
use `Chart.PointPolar` to create a polar plot that displays points on a polar coordinate system:
55+
*)
56+
57+
let pointPolar = Chart.PointPolar(radial,theta)
58+
(*** condition: ipynb ***)
59+
#if IPYNB
60+
pointPolar
61+
#endif // IPYNB
62+
63+
(***hide***)
64+
pointPolar |> GenericChart.toChartHTML
65+
(***include-it-raw***)
66+
67+
(**
68+
## Polar line charts
69+
70+
use `Chart.LinePolar` to create a polar plot that displays a line connecting input the data on a polar coordinate system.
71+
72+
You can for example change the line style using `Chart.withLineStyle`
73+
*)
74+
75+
let linePolar =
76+
Chart.LinePolar(radial,theta)
77+
|> Chart.withLineStyle(Color="purple",Dash=StyleParam.DrawingStyle.DashDot)
78+
79+
(*** condition: ipynb ***)
80+
#if IPYNB
81+
linePolar
82+
#endif // IPYNB
83+
84+
(***hide***)
85+
linePolar |> GenericChart.toChartHTML
86+
(***include-it-raw***)
87+
88+
(**
89+
## Polar Spline charts
90+
91+
use `Chart.SpinePolar` to create a polar plot that displays a smoothed line connecting input the data on a polar coordinate system.
92+
93+
As for all other plots above, You can for example add labels to each datum:
94+
*)
95+
96+
let splinePolar =
97+
Chart.SplinePolar(
98+
radial,
99+
theta,
100+
Labels=["one";"two";"three";"four";"five";"six";"seven"],
101+
TextPosition=StyleParam.TextPosition.TopCenter,
102+
ShowMarkers=true
103+
)
104+
105+
(*** condition: ipynb ***)
106+
#if IPYNB
107+
splinePolar
108+
#endif // IPYNB
109+
110+
(***hide***)
111+
splinePolar |> GenericChart.toChartHTML
112+
(***include-it-raw***)

Diff for: docs/8_1_windrose-charts.fsx renamed to docs/8_1_polar_bar_charts.fsx

+21-11
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
(**
22
---
3-
title: Windrose charts
3+
title: Polar bar charts
44
category: Polar Charts
55
categoryindex: 9
66
index: 2
@@ -20,40 +20,50 @@ index: 2
2020
#endif // IPYNB
2121

2222
(**
23-
# Wind rose charts
23+
# Polar bar charts
2424
2525
[![Binder]({{root}}img/badge-binder.svg)](https://mybinder.org/v2/gh/plotly/Plotly.NET/gh-pages?filepath={{fsdocs-source-basename}}.ipynb) 
2626
[![Script]({{root}}img/badge-script.svg)]({{root}}{{fsdocs-source-basename}}.fsx) 
2727
[![Notebook]({{root}}img/badge-notebook.svg)]({{root}}{{fsdocs-source-basename}}.ipynb)
2828
29-
*Summary:* This example shows how to create wind rose charts in F#.
29+
*Summary:* This example shows how to create polar bar charts in F#.
3030
3131
let's first create some data for the purpose of creating example charts:
3232
3333
*)
3434

3535
open Plotly.NET
3636

37-
let r = [77.5; 72.5; 70.0; 45.0; 22.5; 42.5; 40.0; 62.5]
38-
let r' = [57.5; 50.0; 45.0; 35.0; 20.0; 22.5; 37.5; 55.0]
39-
let r'' = [40.0; 30.0; 30.0; 35.0; 7.5; 7.5; 32.5; 40.0]
40-
let r''' = [20.0; 7.5; 15.0; 22.5; 2.5; 2.5; 12.5; 22.5]
37+
let r = [77.5; 72.5; 70.0; 45.0; 22.5; 42.5; 40.0; 62.5]
38+
let r2 = [57.5; 50.0; 45.0; 35.0; 20.0; 22.5; 37.5; 55.0]
39+
let r3 = [40.0; 30.0; 30.0; 35.0; 7.5; 7.5; 32.5; 40.0]
40+
let r4 = [20.0; 7.5; 15.0; 22.5; 2.5; 2.5; 12.5; 22.5]
4141

4242
let t = ["North"; "N-E"; "East"; "S-E"; "South"; "S-W"; "West"; "N-W"]
4343

4444
(**
45+
Polar bar charts plot data on a radial axis and a categorical angular axis.
46+
47+
A common use case is the **windrose chart**.
48+
4549
A wind rose is a graphic tool used by meteorologists to give a succinct view
4650
of how wind speed and direction are typically distributed at a particular location.
4751
*)
4852

4953
let windrose1 =
5054
[
51-
Chart.WindRose (r ,t,Name="11-14 m/s")
52-
Chart.WindRose (r' ,t,Name="8-11 m/s")
53-
Chart.WindRose (r'' ,t,Name="5-8 m/s")
54-
Chart.WindRose (r''',t,Name="< 5 m/s")
55+
Chart.BarPolar (r , t, Name="11-14 m/s")
56+
Chart.BarPolar (r2, t, Name="8-11 m/s")
57+
Chart.BarPolar (r3, t, Name="5-8 m/s")
58+
Chart.BarPolar (r4, t, Name="< 5 m/s")
5559
]
5660
|> Chart.Combine
61+
|> Chart.withAngularAxis(
62+
Axis.AngularAxis.init(
63+
CategoryOrder = StyleParam.CategoryOrder.Array,
64+
CategoryArray = (["East"; "N-E"; "North"; "N-W"; "West"; "S-W"; "South"; "S-E";]) // set the order of the categorical axis
65+
)
66+
)
5767

5868
(*** condition: ipynb ***)
5969
#if IPYNB

0 commit comments

Comments
 (0)