func xys(data []float64) plotter.XYs {
	points := make(plotter.XYs, len(data))
	for i, datum := range data {
		points[i].X = float64(i)
		points[i].Y = datum
	}
	return points
}
xys turns a slice of float64 values into a plotter.XYs
package main
import (
	"code.google.com/p/plotinum/plot"
	"code.google.com/p/plotinum/plotter"
	"fmt"
	"github.com/purzelrakete/bandit/sim"
	"image/color"
	"strings"
)
type graph map[string][]float64
func rgb(r, g, b uint8) color.RGBA {
	return color.RGBA{r, g, b, 255}
}
func getColor(i int) color.Color {
	defaultColors := []color.Color{
		rgb(241, 90, 96),
		rgb(122, 195, 106),
		rgb(90, 155, 212),
		rgb(250, 167, 91),
		rgb(158, 103, 171),
		rgb(206, 112, 88),
		rgb(215, 127, 180),
	}
	if i > 0 && i <= len(defaultColors) {
		return defaultColors[i]
	}
	return rgb(0, 0, 0)
}
func draw(lines graph, title, xLabel, yLabel string) error {
	p, err := plot.New()
	if err != nil {
		return fmt.Errorf(err.Error())
	}
	p.Title.Text = title
	p.X.Label.Text = xLabel
	p.Y.Label.Text = yLabel
	i := 0
	for legend, data := range lines {
		i = i + 1
		l, err := plotter.NewLine(xys(data))
		if err != nil {
			return fmt.Errorf(err.Error())
		}
		p.Add(l)
		p.Legend.Add(legend, l)
		l.LineStyle.Color = getColor(i)
	}
	if err != nil {
		return fmt.Errorf(err.Error())
	}
	name := strings.Replace(strings.ToLower(title), " ", "-", -1)
	filename := fmt.Sprintf("strategy-%s.svg", name)
	if err := p.Save(8, 8, filename); err != nil {
		return fmt.Errorf(err.Error())
	}
	return nil
}