...

Source file src/gonum.org/v1/plot/plotter/precision_test.go

Documentation: gonum.org/v1/plot/plotter

     1  // Copyright ©2017 The Gonum Authors. All rights reserved.
     2  // Use of this source code is governed by a BSD-style
     3  // license that can be found in the LICENSE file.
     4  
     5  package plotter_test
     6  
     7  import (
     8  	"log"
     9  	"testing"
    10  
    11  	"gonum.org/v1/plot"
    12  	"gonum.org/v1/plot/cmpimg"
    13  	"gonum.org/v1/plot/plotter"
    14  )
    15  
    16  func TestFloatPrecision(t *testing.T) {
    17  	const fname = "precision.png"
    18  
    19  	cmpimg.CheckPlot(func() {
    20  		p := plot.New()
    21  		p.X.Label.Text = "x"
    22  		p.Y.Label.Text = "y"
    23  
    24  		var data = make(plotter.XYs, 10)
    25  		for i := range data {
    26  			data[i].X = float64(i)
    27  			data[i].Y = 1300
    28  		}
    29  
    30  		lines, points, err := plotter.NewLinePoints(data)
    31  		if err != nil {
    32  			log.Fatal(err)
    33  		}
    34  		p.Add(points, lines)
    35  		p.Add(plotter.NewGrid())
    36  
    37  		err = p.Save(300, 300, "testdata/"+fname)
    38  		if err != nil {
    39  			log.Fatal(err)
    40  		}
    41  	}, t, fname)
    42  }
    43  

View as plain text