@@ -43,18 +43,20 @@ let matrix =
43
43
let rownames = [ " p3" ; " p2" ; " p1" ]
44
44
let colnames = [ " Tp0" ; " Tp30" ; " Tp60" ; " Tp160" ]
45
45
46
- let colorscaleValue =
47
- StyleParam.Colorscale.Custom [( 0.0 , " #3D9970" );( 1.0 , " #001f3f" )]
46
+ (**
47
+
48
+ A heatmap chart can be created using the `Chart.Heatmap` functions.
49
+
50
+ When creating heatmap charts, it is usually desirable to provide the values in matrix form, rownames and colnames.
51
+
52
+ A heatmap needs at least 2 dimensional data that represents the z dimension. the X and Y dimension sizes can be inferred from the z data:
53
+ *)
48
54
49
- // Generating the Heatmap
55
+ // Generating the Heatmap with only z Data
50
56
let heat1 =
51
57
Chart.Heatmap(
52
- matrix, colnames, rownames,
53
- Colorscale= colorscaleValue,
54
- Showscale= true
58
+ matrix
55
59
)
56
- |> Chart.withSize( 700. , 500. )
57
- |> Chart.withMarginSize( Left= 200. )
58
60
59
61
(*** condition: ipynb ***)
60
62
#if IPYNB
@@ -66,28 +68,85 @@ heat1 |> GenericChart.toChartHTML
66
68
(***include-it-raw***)
67
69
68
70
(**
69
- A heatmap chart can be created using the `Chart.HeatMap` functions.
70
- When creating heatmap charts, it is usually desirable to provide the values in matrix form, rownames and colnames.
71
+ ## Inverting the Y Axis
72
+
73
+ Per default, the y axis starts at the origin of the X/Y plane.
74
+ If it is however desired to represent a 2D matrix exactly how it is notated, invert the YAxis by setting `ReverseYAxis`.
71
75
*)
72
76
77
+ // Addning row/column names and inverting the Y axis:
78
+ let heat2 =
79
+ Chart.Heatmap(
80
+ matrix,
81
+ colnames,
82
+ rownames,
83
+ ReverseYAxis = true
84
+ )
85
+
86
+ (*** condition: ipynb ***)
87
+ #if IPYNB
88
+ heat2
89
+ #endif // IPYNB
90
+
91
+ (***hide***)
92
+ heat2 |> GenericChart.toChartHTML
93
+ (***include-it-raw***)
94
+
73
95
(**
74
- ## Styling Colorbars
96
+ ## Styling Colorbars and using custom color scales
75
97
98
+ The colorscale can be set via the `ColorScale` argument.
76
99
All charts that contain colorbars can be styled by the `Chart.withColorBarStyle` function.
77
100
Here is an example that adds a title to the colorbar:
78
101
*)
79
102
80
- let heat2 =
81
- heat1
103
+ let heat3 =
104
+ Chart.Heatmap(
105
+ matrix,
106
+ ColorScale = StyleParam.Colorscale.Viridis
107
+ )
82
108
|> Chart.withColorBarStyle(
83
109
Title.init( " Im the ColorBar" )
84
110
)
85
111
86
112
(*** condition: ipynb ***)
87
113
#if IPYNB
88
- heat2
114
+ heat3
89
115
#endif // IPYNB
90
116
91
117
(***hide***)
92
- heat2 |> GenericChart.toChartHTML
118
+ heat3 |> GenericChart.toChartHTML
93
119
(***include-it-raw***)
120
+
121
+
122
+ (**
123
+ ## Annotated Heatmaps
124
+
125
+ use `Chart.AnnotatedHeatmap` to add an annotation text to each z value:
126
+ *)
127
+
128
+ let heat4 =
129
+ Chart.AnnotatedHeatmap(
130
+ zData = [
131
+ [ 1 .. 5 ]
132
+ [ 6 .. 10 ]
133
+ [ 11 .. 15 ]
134
+ ],
135
+ annotationText = [
136
+ [ " 1,1" ; " 1,2" ; " 1,3" ]
137
+ [ " 2,1" ; " 2,2" ; " 2,3" ]
138
+ [ " 3,1" ; " 3,2" ; " 3,3" ]
139
+ ],
140
+ X = [ " C1" ; " C2" ; " C3" ],
141
+ Y = [ " R1" ; " R2" ; " R3" ],
142
+ ReverseYAxis = true
143
+ )
144
+
145
+ (*** condition: ipynb ***)
146
+ #if IPYNB
147
+ heat4
148
+ #endif // IPYNB
149
+
150
+ (***hide***)
151
+ heat4 |> GenericChart.toChartHTML
152
+ (***include-it-raw***)
0 commit comments