You shouldn't have to look at how the error bar plotter draws its lines to
figure out how to pass data into the plotter.
BTW, the error values returned by the error interfaces is two positive numbers
that the plotter automatically subtracts and adds to the middle value for you:
package main
import (
"code.google.com/p/plotinum/plot"
"code.google.com/p/plotinum/plotter"
)
type XYMeanErr []struct {
X float64
YMean, YError float64
}
func (e XYMeanErr) Len() int {
return len(e)
}
func (e XYMeanErr) XY(i int) (x, y float64) {
return e[i].X, e[i].YMean
}
func (e XYMeanErr) YError(i int) (float64, float64) {
yerr := e[i].YError
return yerr, yerr
}
func main() {
data := XYMeanErr{
{0, 10, 5}, {1, 10, 5}, {2, 20, 10},
}
p, err := plot.New()
if err != nil {
panic(err)
}
line, err := plotter.NewLine(data)
if err != nil {
panic(err)
}
yerr, err := plotter.NewYErrorBars(data)
if err != nil {
panic(err)
}
p.Add(line, yerr)
p.Y.Min = 0
if err := p.Save(4, 4, "test.eps"); err != nil {
panic(err)
}
}
Original issue reported on code.google.com by burns.ethan@gmail.com on 7 May 2014 at 11:29
Original issue reported on code.google.com by
burns.ethan@gmail.com
on 7 May 2014 at 11:29