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

Function TestComplexContours

plotter/contour_test.go:75–108  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

73}
74
75func TestComplexContours(t *testing.T) {
76 rnd := rand.New(rand.NewPCG(1, 1))
77
78 if !*visualDebug {
79 return
80 }
81 for _, n := range []float64{0, 1, 2, 4, 8, 16, 32} {
82 data := make([]float64, 6400)
83 for i := range data {
84 r := float64(i/80) - 40
85 c := float64(i%80) - 40
86
87 data[i] = rnd.NormFloat64()*n + math.Hypot(r, c)
88 }
89
90 m := unitGrid{mat.NewDense(80, 80, data)}
91
92 levels := []float64{-1, 3, 7, 9, 13, 15, 19, 23, 27, 31}
93 c := NewContour(m, levels, palette.Rainbow(10, palette.Blue, palette.Red, 1, 1, 1))
94
95 plt := plot.New()
96 plt.X.Padding = 0
97 plt.Y.Padding = 0
98 plt.X.Max = 79.5
99 plt.Y.Max = 79.5
100
101 plt.Add(c)
102
103 err := plt.Save(7*vg.Centimeter, 7*vg.Centimeter, fmt.Sprintf("complex_contour-%v.svg", n))
104 if err != nil {
105 t.Fatalf("could not save plot: %+v", err)
106 }
107 }
108}
109
110func unity(f float64) vg.Length { return vg.Length(f) }
111

Callers

nothing calls this directly

Calls 5

RainbowFunction · 0.92
NewFunction · 0.92
NewContourFunction · 0.85
SaveMethod · 0.80
AddMethod · 0.45

Tested by

no test coverage detected