MCPcopy Create free account
hub / github.com/cogentcore/core / TestErrBar

Function TestErrBar

plot/plots/plot_test.go:287–327  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

285}
286
287func TestErrBar(t *testing.T) {
288 pt := plot.New()
289 pt.Title.Text = "Test Line Errors"
290 pt.X.Label.Text = "X Axis"
291 pt.Y.Min = 0
292 pt.Y.Max = 100
293 pt.Y.Label.Text = "Y Axis"
294
295 data := make(plot.XYs, 21)
296 for i := range data {
297 x := float32(i % 21)
298 data[i].X = x * 5
299 data[i].Y = float32(50) + 40*math32.Sin((x/8)*math32.Pi)
300 }
301
302 yerr := make(YErrors, 21)
303 for i := range yerr {
304 x := float32(i % 21)
305 yerr[i].High = float32(5) + 4*math32.Cos((x/8)*math32.Pi)
306 yerr[i].Low = -yerr[i].High
307 }
308
309 xyerr := XYErr{XYs: data, YErrors: yerr}
310
311 l1, err := NewLine(data)
312 if err != nil {
313 t.Error(err.Error())
314 }
315 pt.Add(l1)
316 pt.Legend.Add("Sine", l1)
317
318 l2, err := NewYErrorBars(xyerr)
319 if err != nil {
320 t.Error(err.Error())
321 }
322 pt.Add(l2)
323
324 pt.Resize(image.Point{640, 480})
325 pt.Draw()
326 imagex.Assert(t, pt.Pixels, "errbar.png")
327}

Callers

nothing calls this directly

Calls 10

NewFunction · 0.92
SinFunction · 0.92
CosFunction · 0.92
AssertFunction · 0.92
NewYErrorBarsFunction · 0.85
NewLineFunction · 0.70
ErrorMethod · 0.65
AddMethod · 0.65
DrawMethod · 0.65
ResizeMethod · 0.45

Tested by

no test coverage detected