gonum / plot

A repository for plotting and visualizing data
BSD 3-Clause "New" or "Revised" License
2.74k stars 203 forks source link

Need better documentation for error bars #169

Closed eaburns closed 9 years ago

eaburns commented 9 years ago

Original issue 141 created by eaburns on 2014-05-07T23:29:40.000Z:

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)
}

}

eaburns commented 9 years ago

Comment #1 originally posted by eaburns on 2014-05-10T14:40:52.000Z:

This issue was closed by revision 1dd666395964.