@@ -11,10 +11,86 @@ Multiple charts and subcharts
11
11
12
12
How to create subplots in FSharp.Plotly. Find examples of combined, stacked, and plots with multiple axis.
13
13
14
+ *)
15
+
16
+
17
+ (**
18
+ ## Chart subplot grids
19
+
20
+ ### Chart.Grid
21
+
22
+ `Chart.Grid` takes a 2D input sequence of charts and creates a subplot grid with the dimensions outerlength x (max (innerLengths))
23
+
24
+
25
+
14
26
*)
15
27
open FSharp.Plotly
16
28
17
29
30
+ //simple 3x3 subplot grid
31
+ let grid =
32
+ Chart.Grid(
33
+ [
34
+ [ Chart.Point([( 0 , 1 )]); Chart.Point([( 0 , 1 )]); Chart.Point([( 0 , 1 )]);]
35
+ [ Chart.Point([( 0 , 1 )]); Chart.Point([( 0 , 1 )]); Chart.Point([( 0 , 1 )]);]
36
+ [ Chart.Point([( 0 , 1 )]); Chart.Point([( 0 , 1 )]); Chart.Point([( 0 , 1 )]);]
37
+ ]
38
+ )
39
+
40
+ (***do-not-eval***)
41
+ grid |> Chart.Show
42
+
43
+ (*** include-value:grid ***)
44
+
45
+
46
+ (**
47
+ use `sharedAxis=true` to use one shared x axis per column and one shared y axis per row.
48
+ (Try zooming in the single subplots below)
49
+ *)
50
+
51
+ let grid2 =
52
+ Chart.Grid(
53
+ [
54
+ [ Chart.Point([( 0 , 1 )]); Chart.Point([( 0 , 1 )]); Chart.Point([( 0 , 1 )]);]
55
+ [ Chart.Point([( 0 , 1 )]); Chart.Point([( 0 , 1 )]); Chart.Point([( 0 , 1 )]);]
56
+ [ Chart.Point([( 0 , 1 )]); Chart.Point([( 0 , 1 )]); Chart.Point([( 0 , 1 )]);]
57
+ ], sharedAxes= true , rowOrder = StyleParam.LayoutGridRowOrder.BottomToTop
58
+ )
59
+
60
+ (***do-not-eval***)
61
+ grid2 |> Chart.Show
62
+
63
+ (*** include-value:grid2 ***)
64
+
65
+
66
+ (**
67
+ ### Chart.SingleStack
68
+
69
+ The `Chart.SingleStack` function is a special version of Chart.Grid that creates only one column from a 1D input chart sequence.
70
+ It uses a shared x axis per default. You can also use the Chart.withLayoutGridStyle to further style subplot grids:
71
+
72
+ *)
73
+
74
+ let singleStack =
75
+ [
76
+ Chart.Point([( 0 , 1 )]) |> Chart.withY_ AxisStyle( " This title must" )
77
+ Chart.Point([( 0 , 1 )])
78
+ |> Chart.withY_ AxisStyle( " be set on the" , Zeroline= false )
79
+ Chart.Point([( 0 , 1 )])
80
+ |> Chart.withY_ AxisStyle( " respective subplots" , Zeroline= false )
81
+ ]
82
+ |> Chart.SingleStack
83
+ //move xAxis to bottom and increase spacing between plots by using the withLayoutGridStyle function
84
+ |> Chart.withLayoutGridStyle( XSide= StyleParam.LayoutGridXSide.Bottom, YGap= 0.1 )
85
+ |> Chart.withTitle( " Hi i am the new SingleStackChart" )
86
+ |> Chart.withX_ AxisStyle( " im the shared xAxis" )
87
+
88
+
89
+ (***do-not-eval***)
90
+ singleStack |> Chart.Show
91
+
92
+ (*** include-value:singleStack ***)
93
+
18
94
(**
19
95
Functional F# scripting style for Two Y-Axes
20
96
*)
@@ -56,22 +132,3 @@ let twoYaxesSide =
56
132
twoYaxesSide |> Chart.Show
57
133
58
134
(*** include-value:twoYaxesSide ***)
59
-
60
- (**
61
- Functional F# scripting style simple subplot stacked 2 columns.
62
- Axis style (like: title) is taken from the single chart, but can also be styled by axis id.
63
- *)
64
-
65
- let stack =
66
- [
67
- for i= 1 to 8 do
68
- yield Chart.Scatter ([ 1 ; 2 ; 3 ; 4 ],[ 12 ; 9 ; 15 ; 12 ], StyleParam.Mode.Lines_ Markers)
69
- |> Chart.withY_ AxisStyle( sprintf " y-title %i " i)
70
- ]
71
- |> Chart.Stack( Columns= 2 , Space= 0.15 )
72
- |> Chart.withX_ AxisStyle( sprintf " x-title %i " 3 , Id= 3 )
73
-
74
- (***do-not-eval***)
75
- stack |> Chart.Show
76
-
77
- (*** include-value:stack ***)
0 commit comments