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

Method Plot

plotter/colorbar.go:55–88  ·  view source on GitHub ↗

Plot implements the Plot method of the plot.Plotter interface.

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

Source from the content-addressed store, hash-verified

53
54// Plot implements the Plot method of the plot.Plotter interface.
55func (l *ColorBar) Plot(c draw.Canvas, p *plot.Plot) {
56 l.check()
57 colors := l.colors(c)
58 var pImg *Image
59 delta := (l.ColorMap.Max() - l.ColorMap.Min()) / float64(colors)
60 if l.Vertical {
61 img := image.NewNRGBA64(image.Rectangle{
62 Min: image.Point{X: 0, Y: 0},
63 Max: image.Point{X: 1, Y: colors},
64 })
65 for i := range colors {
66 color, err := l.ColorMap.At(l.ColorMap.Min() + delta*float64(i))
67 if err != nil {
68 panic(err)
69 }
70 img.Set(0, colors-1-i, color)
71 }
72 pImg = NewImage(img, 0, l.ColorMap.Min(), 1, l.ColorMap.Max())
73 } else {
74 img := image.NewNRGBA64(image.Rectangle{
75 Min: image.Point{X: 0, Y: 0},
76 Max: image.Point{X: colors, Y: 1},
77 })
78 for i := range colors {
79 color, err := l.ColorMap.At(l.ColorMap.Min() + delta*float64(i))
80 if err != nil {
81 panic(err)
82 }
83 img.Set(i, 0, color)
84 }
85 pImg = NewImage(img, l.ColorMap.Min(), 0, l.ColorMap.Max(), 1)
86 }
87 pImg.Plot(c, p)
88}
89
90// DataRange implements the DataRange method
91// of the plot.DataRanger interface.

Callers

nothing calls this directly

Calls 7

checkMethod · 0.95
colorsMethod · 0.95
PlotMethod · 0.95
NewImageFunction · 0.85
MaxMethod · 0.65
MinMethod · 0.65
AtMethod · 0.65

Tested by

no test coverage detected