| 15 | ) |
| 16 | |
| 17 | func TestFloatPrecision(t *testing.T) { |
| 18 | const fname = "precision_" + runtime.GOARCH + ".png" |
| 19 | |
| 20 | cmpimg.CheckPlot(func() { |
| 21 | p := plot.New() |
| 22 | p.X.Label.Text = "x" |
| 23 | p.Y.Label.Text = "y" |
| 24 | |
| 25 | var data = make(plotter.XYs, 10) |
| 26 | for i := range data { |
| 27 | data[i].X = float64(i) |
| 28 | data[i].Y = 1300 |
| 29 | } |
| 30 | |
| 31 | lines, points, err := plotter.NewLinePoints(data) |
| 32 | if err != nil { |
| 33 | log.Fatal(err) |
| 34 | } |
| 35 | p.Add(points, lines) |
| 36 | p.Add(plotter.NewGrid()) |
| 37 | |
| 38 | err = p.Save(300, 300, "testdata/"+fname) |
| 39 | if err != nil { |
| 40 | log.Fatal(err) |
| 41 | } |
| 42 | }, t, fname) |
| 43 | } |