MCPcopy Index your code
hub / github.com/gonum/plot / plotRasterized

Method plotRasterized

plotter/heat.go:114–146  ·  view source on GitHub ↗

plotRasterized plots the heatmap using raster-based drawing.

(c draw.Canvas, plt *plot.Plot)

Source from the content-addressed store, hash-verified

112
113// plotRasterized plots the heatmap using raster-based drawing.
114func (h *HeatMap) plotRasterized(c draw.Canvas, plt *plot.Plot) {
115 cols, rows := h.GridXYZ.Dims()
116 img := image.NewRGBA64(image.Rectangle{
117 Min: image.Point{X: 0, Y: 0},
118 Max: image.Point{X: cols, Y: rows},
119 })
120
121 pal := h.Palette.Colors()
122 ps := float64(len(pal)-1) / (h.Max - h.Min)
123 for i := range cols {
124 for j := range rows {
125 var col color.Color
126 switch v := h.GridXYZ.Z(i, j); {
127 case v < h.Min:
128 col = h.Underflow
129 case v > h.Max:
130 col = h.Overflow
131 case math.IsNaN(v), math.IsInf(ps, 0):
132 col = h.NaN
133 default:
134 col = pal[int((v-h.Min)*ps+0.5)] // Apply palette scaling.
135 }
136
137 if col != nil {
138 img.Set(i, rows-j-1, col)
139 }
140 }
141 }
142
143 xmin, xmax, ymin, ymax := h.DataRange()
144 pImg := NewImage(img, xmin, ymin, xmax, ymax)
145 pImg.Plot(c, plt)
146}
147
148// plotVectorized plots the heatmap using vector-based drawing.
149func (h *HeatMap) plotVectorized(c draw.Canvas, plt *plot.Plot) {

Callers 1

PlotMethod · 0.95

Calls 6

DataRangeMethod · 0.95
PlotMethod · 0.95
NewImageFunction · 0.85
DimsMethod · 0.65
ColorsMethod · 0.65
ZMethod · 0.65

Tested by

no test coverage detected