-
Notifications
You must be signed in to change notification settings - Fork 81
/
03_0_3d-scatter-plots.fsx
171 lines (135 loc) · 3.9 KB
/
03_0_3d-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
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
(**
---
title: 3D point and line charts
category: 3D Charts
categoryindex: 4
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
(**
# 3D point plots
[![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 three-dimensional point and line charts in F#.
Point3D, Line3D, and Bubble3D charts are all derived from `Chart.Scatter3D` and can be generated by that function as well.
However, `Chart.Point3D`, `Chart.Line3D`, or `Chart.Bubble3D` provide sensible defaults and arguments for the respective derived chart, and are recommended to use.
## 3D point chart
*)
open Plotly.NET
let point3d =
Chart.Point3D(
[1,3,2; 6,5,4; 7,9,8],
MultiText = ["A"; "B"; "C"],
TextPosition = StyleParam.TextPosition.BottomCenter
)
|> Chart.withXAxisStyle("my x-axis", Id=StyleParam.SubPlotId.Scene 1) // in contrast to 2D plots, x and y axes of 3D charts have to be set via the scene object
|> Chart.withYAxisStyle("my y-axis", Id=StyleParam.SubPlotId.Scene 1) // in contrast to 2D plots, x and y axes of 3D charts have to be set via the scene object
|> Chart.withZAxisStyle("my z-axis")
|> Chart.withSize(800.,800.)
(*** condition: ipynb ***)
#if IPYNB
point3d
#endif // IPYNB
(***hide***)
point3d |> GenericChart.toChartHTML
(*** include-it-raw ***)
(**
## 3D point chart with marker colorscale
*)
let point3d2 =
Chart.Point3D(
[1,3,2; 6,5,4; 7,9,8],
MarkerColor = Color.fromColorScaleValues [0;1;2],
MultiText = ["A"; "B"; "C"],
TextPosition = StyleParam.TextPosition.BottomCenter
)
(*** condition: ipynb ***)
#if IPYNB
point3d2
#endif // IPYNB
(***hide***)
point3d2 |> GenericChart.toChartHTML
(*** include-it-raw ***)
(**
# 3D Line chart
*)
let line3d =
Chart.Line3D(
[1,3,2; 6,5,4; 7,9,8],
MultiText = ["A"; "B"; "C"],
TextPosition = StyleParam.TextPosition.BottomCenter,
ShowMarkers = true
)
(*** condition: ipynb ***)
#if IPYNB
line3d
#endif // IPYNB
(***hide***)
line3d |> GenericChart.toChartHTML
(*** include-it-raw ***)
(**
## 3D line chart with line colorscale
*)
let line3d2 =
Chart.Line3D(
[1,3,2; 6,5,4; 7,9,8],
MultiText = ["A"; "B"; "C"],
TextPosition = StyleParam.TextPosition.BottomCenter,
ShowMarkers = true,
LineColor = Color.fromColorScaleValues [0;1;2],
LineWidth = 10.
)
(*** condition: ipynb ***)
#if IPYNB
line3d2
#endif // IPYNB
(***hide***)
line3d2 |> GenericChart.toChartHTML
(*** include-it-raw ***)
(**
# 3D Bubble plots
*)
let bubble3d =
Chart.Bubble3D(
[1,3,2; 6,5,4; 7,9,8],
[10;20;30],
MultiText = ["A"; "B"; "C"],
TextPosition = StyleParam.TextPosition.BottomCenter
)
(*** condition: ipynb ***)
#if IPYNB
bubble3d
#endif // IPYNB
(***hide***)
bubble3d |> GenericChart.toChartHTML
(*** include-it-raw ***)
(**
## 3D bubble chart with colorscale
*)
let bubble3d2 =
Chart.Bubble3D(
[1,3,2; 6,5,4; 7,9,8],
[10;20;30],
MultiText = ["A"; "B"; "C"],
TextPosition = StyleParam.TextPosition.BottomCenter,
MarkerColor = Color.fromColorScaleValues [0;1;2],
MarkerColorScale = StyleParam.Colorscale.Viridis
)
(*** condition: ipynb ***)
#if IPYNB
bubble3d2
#endif // IPYNB
(***hide***)
bubble3d2 |> GenericChart.toChartHTML
(*** include-it-raw ***)