-
Notifications
You must be signed in to change notification settings - Fork 1
Heatmap
Heatmap plot is one of the plot types that can be added to the chart and renders values defined on a rectangular grid using color palette.
To create a heatmap plot you need three arrays: X: float[]
, Y: float[]
and Data: float[,]
.
let heatmap = createHeatmap X Y Data
Actually the heatmap plot is a record of type FSharpIDD.Plots.Heatmap.Plot
You can also create it by explicitly filling up all record fields:
{
/// Specifies how to annotate Heatmap plot in a legend
Name: string
/// X coords of grid points. If missing is considered to be sequential integers. Should have at least 2 elements
X: float[]
/// Y coords of grid points. If missing is considered to be sequential integers. Should have at least 2 elements
Y: float[]
/// Two-dimensional array of values in grid points. If value is NaN, the point is skipped
Data: float[,]
/// Colour palette
Palette: Palette
/// Heatmap transparency in [0, 1] domain, where 0 - transparent, 1 - opaque
Opacity: float
}
The heatmap plot has three appearance options that can be configured:
- Name (as it's seen in a legend)
- Palette (color palette definition syntax)
- Opacity (from 0 to 1)
You can use the following functions of the module FSharpIDD.Plots.Heatmap
to define the options respectively:
setName: name:string -> heatmap:Plot -> Plot
setPalette: palette:string -> heatmap:Plot -> Plot
setOpacity: opacity:float -> heatmap:Plot -> Plot
let heatmap1 =
createHeatmap X Y Data
|> setName "Heatmap 1"
|> setPalette "#420943=0.01=#556270=0.05=#025D8C=0.1=#1693A5=#69D2E7=0.3=#A7DBD8=#E0E4CC=#F38630=#FA6900"
|> setOpacity 0.8
There is also an option to set several appearance characteristics with a single setOptions: options:Options -> heatmap:Plot -> Plot
call.
The convenience of the method is that you can define several (but not necessarily all) options during Options
value creation.
let heatmapOptions = Options(Name = "Heatmap1", Palette = "-1.0=blue,white,red=1.0", Opacity=0.5)
let heatmapPlot =
createHeatmap X Y Data
|> setOptions heatmapOptions
If number of values in arrays of coordinates are equal to corresponding dimensions of data array then heatmap is rendered in a gradient mode. It means that each cell of the grid has four colors defined in the corners of the cell and color within the cell is interpolated. If number of coordinate values are greater by one than dimensions of data then heatmap is rendered in a matrix, or bitmap, mode, when a cell(i,j) is built so that each point(xi,yj) is in the middle of that cell which color is defined by fij.