MCPcopy Create free account
hub / github.com/gonum/plot / NewHeatMap

Function NewHeatMap

plotter/heat.go:72–102  ·  view source on GitHub ↗

NewHeatMap creates as new heat map plotter for the given data, using the provided palette. If g has Min and Max methods that return a float, those returned values are used to set the respective HeatMap fields. If the returned HeatMap is used when Min is greater than Max, the Plot method will panic.

(g GridXYZ, p palette.Palette)

Source from the content-addressed store, hash-verified

70// fields. If the returned HeatMap is used when Min is greater than Max,
71// the Plot method will panic.
72func NewHeatMap(g GridXYZ, p palette.Palette) *HeatMap {
73 var min, max float64
74 type minMaxer interface {
75 Min() float64
76 Max() float64
77 }
78 switch g := g.(type) {
79 case minMaxer:
80 min, max = g.Min(), g.Max()
81 default:
82 min, max = math.Inf(1), math.Inf(-1)
83 c, r := g.Dims()
84 for i := range c {
85 for j := range r {
86 v := g.Z(i, j)
87 if math.IsNaN(v) {
88 continue
89 }
90 min = math.Min(min, v)
91 max = math.Max(max, v)
92 }
93 }
94 }
95
96 return &HeatMap{
97 GridXYZ: g,
98 Palette: p,
99 Min: min,
100 Max: max,
101 }
102}
103
104// Plot implements the Plot method of the plot.Plotter interface.
105func (h *HeatMap) Plot(c draw.Canvas, plt *plot.Plot) {

Callers 6

ExampleHeatMapFunction · 0.92
TestHeatMapDimsFunction · 0.92
Example_volcanoFunction · 0.92
ExampleFunction · 0.92
TestHeatMapWithContourFunction · 0.85

Calls 4

MinMethod · 0.65
MaxMethod · 0.65
DimsMethod · 0.65
ZMethod · 0.65

Tested by 6

ExampleHeatMapFunction · 0.74
TestHeatMapDimsFunction · 0.74
Example_volcanoFunction · 0.74
ExampleFunction · 0.74
TestHeatMapWithContourFunction · 0.68