@@ -33,26 +33,62 @@ let's first create some data for the purpose of creating example charts:
3333
3434*)
3535
36- open Plotly.NET
36+
37+ #r " nuget: FSharp.Data"
38+ #r " nuget: Deedle"
39+
40+ open FSharp.Data
41+ open Deedle
42+ open Plotly.NET
3743
3844let data =
39- [
40- " A" ,[| 1. ; 4. ; 3.4 ; 0.7 ;|]
41- " B" ,[| 3. ; 1.5 ; 1.7 ; 2.3 ;|]
42- " C" ,[| 2. ; 4. ; 3.1 ; 5. |]
43- " D" ,[| 4. ; 2. ; 2. ; 4. ;|]
44- ]
45+ Http.RequestString @" https://raw.githubusercontent.com/plotly/datasets/master/iris-data.csv"
46+ |> fun csv -> Frame.ReadCsvString( csv, true , separators= " ," )
47+
48+ let sepalLengthData = data.[ " sepal length" ] |> Series.values
49+ let sepalWidthData = data.[ " sepal width" ] |> Series.values
50+ let petalLengthData = data.[ " petal length" ] |> Series.values
51+ let petalWidthData = data.[ " petal width" ] |> Series.values
52+
53+ let colors =
54+ data
55+ |> Frame.getCol " class"
56+ |> Series.values
57+ |> Seq.cast< string>
58+ |> Seq.map ( fun x ->
59+ match x with
60+ | " Iris-setosa" -> 0.
61+ | " Iris-versicolor" -> 0.5
62+ | _ -> 1.
63+ )
64+ |> Color.fromColorScaleValues
65+
4566
4667(**
4768Using a scatterplot matrix of several different variables can help to determine whether there are any
4869relationships among the variables in the dataset.
4970
50- **Attention**: this function is not very well tested and does not use the `Chart.Grid` functionality.
51- Until that is fixed, consider creating splom plot programatically using `Chart.Grid` for more control.
71+ ## Splom of the iris dataset
5272*)
5373
54- let splom1 =
55- Chart.Splom( data, Color= Color.fromString " blue" )
74+ let splom1 =
75+ Chart.Splom(
76+ [
77+ " sepal length" , sepalLengthData
78+ " sepal width" , sepalWidthData
79+ " petal length" , petalLengthData
80+ " petal width" , petalWidthData
81+ ],
82+ MarkerColor = colors
83+ )
84+ |> Chart.withLayout(
85+ Layout.init(
86+ HoverMode = StyleParam.HoverMode.Closest,
87+ DragMode = StyleParam.DragMode.Select
88+ )
89+ )
90+ |> Chart.withSize ( 1000 , 1000 )
91+
5692
5793(* ** condition: ipynb ***)
5894#if IPYNB
@@ -63,7 +99,50 @@ splom1
6399splom1 |> GenericChart.toChartHTML
64100(* **include-it-raw***)
65101
102+ (**
103+ ## Showing different parts of the plot matrix
66104
105+ Use `ShowDiagonal`, `ShowUpperHalf` or `ShowLowerHalf` to customize the cells shown in the scatter plot matrix.
67106
107+ Here are some examples:
108+ *)
68109
110+ let noDiagonal =
111+ Chart.Splom(
112+ [
113+ " sepal length" , sepalLengthData
114+ " sepal width" , sepalWidthData
115+ " petal length" , petalLengthData
116+ " petal width" , petalWidthData
117+ ],
118+ MarkerColor = colors,
119+ ShowDiagonal = false
120+ )
121+ |> Chart.withLayout(
122+ Layout.init(
123+ HoverMode = StyleParam.HoverMode.Closest,
124+ DragMode = StyleParam.DragMode.Select
125+ )
126+ )
127+ |> Chart.withSize ( 1000 , 1000 )
128+
129+
130+ let noLowerHalf =
131+ Chart.Splom(
132+ [
133+ " sepal length" , sepalLengthData
134+ " sepal width" , sepalWidthData
135+ " petal length" , petalLengthData
136+ " petal width" , petalWidthData
137+ ],
138+ MarkerColor = colors,
139+ ShowLowerHalf = false
140+ )
141+ |> Chart.withLayout(
142+ Layout.init(
143+ HoverMode = StyleParam.HoverMode.Closest,
144+ DragMode = StyleParam.DragMode.Select
145+ )
146+ )
147+ |> Chart.withSize ( 1000 , 1000 )
69148
0 commit comments