...

Source file src/gonum.org/v1/plot/vg/vgsvg/vgsvg_example_test.go

Documentation: gonum.org/v1/plot/vg/vgsvg

     1  // Copyright ©2019 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 vgsvg_test
     6  
     7  import (
     8  	"log"
     9  
    10  	"gonum.org/v1/plot"
    11  	"gonum.org/v1/plot/plotter"
    12  	"gonum.org/v1/plot/vg"
    13  )
    14  
    15  func Example() {
    16  	p := plot.New()
    17  	p.Title.Text = "Scatter plot"
    18  	p.X.Label.Text = "X"
    19  	p.Y.Label.Text = "Y"
    20  
    21  	scatter, err := plotter.NewScatter(plotter.XYs{{X: 1, Y: 1}, {X: 0, Y: 1}, {X: 0, Y: 0}})
    22  	if err != nil {
    23  		log.Fatalf("could not create scatter: %v", err)
    24  	}
    25  	p.Add(scatter)
    26  
    27  	err = p.Save(5*vg.Centimeter, 5*vg.Centimeter, "testdata/scatter.svg")
    28  	if err != nil {
    29  		log.Fatalf("could not save SVG plot: %v", err)
    30  	}
    31  }
    32  

View as plain text