Skip to content

Finish 3d charts #243

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 8 commits into from
Nov 18, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion docs/01_2_multiple-charts.fsx
Original file line number Diff line number Diff line change
Expand Up @@ -255,7 +255,7 @@ let multipleTraceTypesGrid =
Chart.Point([1,2; 2,3])
Chart.PointTernary([1,2,3; 2,3,4])
Chart.Heatmap([[1; 2];[3; 4]], ShowScale=false)
Chart.Point3d([1,3,2])
Chart.Point3D([1,3,2])
Chart.PointMapbox([1,2]) |> Chart.withMapbox(Mapbox.init(Style = StyleParam.MapboxStyle.OpenStreetMap))
[
// you can use nested combined charts, but they have to have the same trace type (Cartesian2D in this case)
Expand Down
89 changes: 80 additions & 9 deletions docs/03_0_3d-scatter-plots.fsx
Original file line number Diff line number Diff line change
Expand Up @@ -30,15 +30,18 @@ index: 1

*Summary:* This example shows how to create three-dimensional point and line charts in F#.

A Scatter3d chart report shows a three-dimensional spinnable view of your data
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(
Chart.Point3D(
[1,3,2; 6,5,4; 7,9,8],
Labels = ["A"; "B"; "C"],
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
Expand All @@ -55,16 +58,35 @@ point3d
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 plots
# 3D Line chart
*)

let line3d =
Chart.Line3d(
Chart.Line3D(
[1,3,2; 6,5,4; 7,9,8],
Labels = ["A"; "B"; "C"],
MultiText = ["A"; "B"; "C"],
TextPosition = StyleParam.TextPosition.BottomCenter,
ShowMarkers = true
)
Expand All @@ -78,15 +100,39 @@ line3d
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(
Chart.Bubble3D(
[1,3,2; 6,5,4; 7,9,8],
[10;20;30],
Labels = ["A"; "B"; "C"],
MultiText = ["A"; "B"; "C"],
TextPosition = StyleParam.TextPosition.BottomCenter
)

Expand All @@ -97,4 +143,29 @@ bubble3d

(***hide***)
bubble3d |> GenericChart.toChartHTML
(*** include-it-raw ***)
(*** 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 ***)

14 changes: 4 additions & 10 deletions docs/03_2_3d-mesh-plots.fsx
Original file line number Diff line number Diff line change
Expand Up @@ -65,16 +65,10 @@ let c = Array.init 50 (fun _ -> rnd.NextDouble())
open Plotly.NET.TraceObjects

let mesh3d =
Trace3D.initMesh3d
(fun mesh3d ->
mesh3d?x <- a
mesh3d?y <- b
mesh3d?z <- c
mesh3d?flatshading <- true
mesh3d?contour <- Contours.initXyz(Show=true)
mesh3d
)
|> GenericChart.ofTraceObject true
Chart.Mesh3D(
a,b,c,
FlatShading = true
)

(*** condition: ipynb ***)
#if IPYNB
Expand Down
5 changes: 2 additions & 3 deletions docs/03_4_3d-streamtube-plots.fsx
Original file line number Diff line number Diff line change
Expand Up @@ -52,13 +52,12 @@ let streamTube =
u = (tubeData.["u"] |> Series.values),
v = (tubeData.["v"] |> Series.values),
w = (tubeData.["w"] |> Series.values),
Starts =
TubeStarts =
StreamTubeStarts.init(
X = Array.init 16 (fun _ -> 80),
Y = [20;30;40;50;20;30;40;50;20;30;40;50;20;30;40;50],
Z = [0;0;0;0;5;5;5;5;10;10;10;10;15;15;15;15]
),
ColorScale = StyleParam.Colorscale.Viridis
)
)


Expand Down
3 changes: 1 addition & 2 deletions docs/03_5_3d-volume-plots.fsx
Original file line number Diff line number Diff line change
Expand Up @@ -70,8 +70,7 @@ let volume =
Opacity=0.1,
Surface=(Surface.init(Count=17)),
IsoMin=0.1,
IsoMax=0.8,
ColorScale = StyleParam.Colorscale.Viridis
IsoMax=0.8
)

(*** condition: ipynb ***)
Expand Down
3 changes: 1 addition & 2 deletions docs/03_6_3d-isosurface-plots .fsx
Original file line number Diff line number Diff line change
Expand Up @@ -73,8 +73,7 @@ let isoSurface =
X = (CapFill.init(Show=false)),
Y = (CapFill.init(Show=false))
),
Surface = Surface.init(Count=5),
ColorScale = StyleParam.Colorscale.Viridis
Surface = Surface.init(Count=5)
)

(*** condition: ipynb ***)
Expand Down
Loading