A key function that allows us to do this is the plot.Align function. For us to see this in action, we need to write a that allows us to plot any number of plots to a file, as follows:
func writeToPng(a interface{}, title, filename string, width, height vg.Length) { switch at := a.(type) { case *plot.Plot: dieIfErr(at.Save(width*vg.Centimeter, height*vg.Centimeter, filename)) return case [][]*plot.Plot: rows := len(at) cols := len(at[0]) t := draw.Tiles{ Rows: rows, Cols: cols, } img := vgimg.New(width*vg.Centimeter, height*vg.Centimeter) dc := draw.New(img) if title != "" { at[0][0].Title.Text = title } canvases := plot.Align(at, t, dc) for i := 0; i < t.Rows; i++ { for j := 0; j < t.Cols; j++ { at[i][j].Draw(canvases[i][j]) ...