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

Function NewContour

plotter/contour.go:56–92  ·  view source on GitHub ↗

NewContour creates as new contour plotter for the given data, using the provided palette. If levels is nil, contours are generated for the 0.01, 0.05, 0.25, 0.5, 0.75, 0.95 and 0.99 quantiles. If g has Min and Max methods that return a float, those returned values are used to set the respective Cont

(g GridXYZ, levels []float64, p palette.Palette)

Source from the content-addressed store, hash-verified

54// If the returned Contour is used when Min is greater than Max, the
55// Plot method will panic.
56func NewContour(g GridXYZ, levels []float64, p palette.Palette) *Contour {
57 var min, max float64
58 type minMaxer interface {
59 Min() float64
60 Max() float64
61 }
62 switch g := g.(type) {
63 case minMaxer:
64 min, max = g.Min(), g.Max()
65 default:
66 min, max = math.Inf(1), math.Inf(-1)
67 c, r := g.Dims()
68 for i := range c {
69 for j := range r {
70 v := g.Z(i, j)
71 if math.IsNaN(v) {
72 continue
73 }
74 min = math.Min(min, v)
75 max = math.Max(max, v)
76 }
77 }
78 }
79
80 if len(levels) == 0 {
81 levels = quantilesR7(g, defaultQuantiles)
82 }
83
84 return &Contour{
85 GridXYZ: g,
86 Levels: levels,
87 LineStyles: []draw.LineStyle{DefaultLineStyle},
88 Palette: p,
89 Min: min,
90 Max: max,
91 }
92}
93
94// Default quantiles for case where levels is not explicitly set.
95var defaultQuantiles = []float64{0.01, 0.05, 0.25, 0.5, 0.75, 0.95, 0.99}

Callers 4

ExampleContourFunction · 0.92
Example_volcanoFunction · 0.92
TestHeatMapWithContourFunction · 0.85
TestComplexContoursFunction · 0.85

Calls 5

quantilesR7Function · 0.85
MinMethod · 0.65
MaxMethod · 0.65
DimsMethod · 0.65
ZMethod · 0.65

Tested by 4

ExampleContourFunction · 0.74
Example_volcanoFunction · 0.74
TestHeatMapWithContourFunction · 0.68
TestComplexContoursFunction · 0.68