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

Function clippedFilledLine

plotter/filledLine_test.go:20–59  ·  view source on GitHub ↗

See https://github.com/gonum/plot/issues/488

()

Source from the content-addressed store, hash-verified

18
19// See https://github.com/gonum/plot/issues/488
20func clippedFilledLine() {
21 rnd := rand.New(rand.NewPCG(1, 1))
22
23 // randomPoints returns some random x, y points
24 // with some interesting kind of trend.
25 randomPoints := func(n int, x float64) plotter.XYs {
26 pts := make(plotter.XYs, n)
27 for i := range pts {
28 if i == 0 {
29 pts[i].X = x + rnd.Float64()
30 } else {
31 pts[i].X = pts[i-1].X + 0.5 + rnd.Float64()
32 }
33 pts[i].Y = -5. + 10*rnd.Float64()
34 }
35 return pts
36 }
37
38 p := plot.New()
39 p.Title.Text = "Filled Line Example"
40 p.X.Label.Text = "X"
41 p.Y.Label.Text = "Y"
42 p.Add(plotter.NewGrid())
43
44 filled, err := plotter.NewLine(randomPoints(4, 0))
45 if err != nil {
46 log.Panic(err)
47 }
48 filled.FillColor = color.RGBA{R: 196, G: 255, B: 196, A: 255}
49
50 p.Add(filled)
51 // testing clipping
52 p.X.Min, p.X.Max = 1, 3.5
53 p.Y.Max = 4
54
55 err = p.Save(200, 200, "testdata/clippedFilledLine.png")
56 if err != nil {
57 log.Panic(err)
58 }
59}
60
61func TestFilledLine(t *testing.T) {
62 cmpimg.CheckPlot(ExampleLine_filledLine, t, "filledLine_"+runtime.GOARCH+".png")

Callers

nothing calls this directly

Calls 6

NewFunction · 0.92
NewGridFunction · 0.92
NewLineFunction · 0.92
randomPointsFunction · 0.85
SaveMethod · 0.80
AddMethod · 0.45

Tested by

no test coverage detected