Exemple #1
0
func test_point() {
	rand.Seed(int64(0))
	points_data := randomPoint(200)
	points_data2 := randomPoint(50)
	p, err := plot.New()
	if err != nil {
		panic(err)
	}

	p.Title.Text = "Points"
	p.X.Label.Text = "X"
	p.Y.Label.Text = "Y"

	bs, _ := plotter.NewBubbles(points_data, vg.Points(5), vg.Points(5))
	bs2, _ := plotter.NewBubbles(points_data2, vg.Points(5), vg.Points(5))

	bs.Color = color.RGBA{R: 255, G: 0, B: 0, A: 255}
	bs2.Color = color.RGBA{R: 0, G: 255, B: 0, A: 255}
	p.Add(bs)
	p.Add(bs2)

	if err := p.Save(10, 10, "points.png"); err != nil {
		panic(err)
	}
}
Exemple #2
0
func Example_bubbles() *plot.Plot {
	rand.Seed(int64(0))
	n := 10
	bubbleData := randomTriples(n)

	p, err := plot.New()
	if err != nil {
		panic(err)
	}
	p.Title.Text = "Bubbles"
	p.X.Label.Text = "X"
	p.Y.Label.Text = "Y"

	bs := plotter.NewBubbles(bubbleData, vg.Points(1), vg.Points(20))
	bs.Color = color.RGBA{R: 196, B: 128, A: 255}
	p.Add(bs)

	return p
}
Exemple #3
0
func test2() {
	rand.Seed(int64(0))
	n := 100
	bubbleData := randomTriples(n)

	p, err := plot.New()
	if err != nil {
		panic(err)
	}
	p.Title.Text = "Bubbles"
	p.X.Label.Text = "X"
	p.Y.Label.Text = "Y"

	bs, err := plotter.NewBubbles(bubbleData, vg.Points(5), vg.Points(5))
	if err != nil {
		panic(err)
	}
	bs.Color = color.RGBA{R: 196, B: 128, A: 255}
	p.Add(bs)

	if err := p.Save(10, 5, "bubble.png"); err != nil {
		panic(err)
	}
}