// Plot plots only 2-dimensional cluster and points func (em EM) Plot(fileid int, directory string) { p, err := plot.New() if err != nil { panic(err) } p.Title.Text = "EM-Algorithm Plot" p.X.Label.Text = "X" p.Y.Label.Text = "Y" bs, err := plotter.NewBubbles(em.clusterTriples(), vg.Points(30), vg.Points(80)) if err != nil { panic(err) } bs.Color = color.RGBA{R: 255, B: 255, A: 255} p.Add(bs) ss, err := plotter.NewScatter(em.dataTriples()) if err != nil { panic(err) } ss.Color = color.Black p.Add(ss) filename := directory + fmt.Sprintf("%03d", fileid) + ".png" if err := p.Save(10*vg.Inch, 10*vg.Inch, filename); err != nil { panic(err) } }
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, err := plotter.NewBubbles(bubbleData, vg.Points(1), vg.Points(20)) if err != nil { panic(err) } bs.Color = color.RGBA{R: 196, B: 128, A: 255} p.Add(bs) return p }