()
| 13 | ) |
| 14 | |
| 15 | func ExampleErrorPoints() { |
| 16 | rnd := rand.New(rand.NewPCG(1, 1)) |
| 17 | |
| 18 | // Get some random data. |
| 19 | n, m := 5, 10 |
| 20 | pts := make([]plotter.XYer, n) |
| 21 | for i := range pts { |
| 22 | xys := make(plotter.XYs, m) |
| 23 | pts[i] = xys |
| 24 | center := float64(i) |
| 25 | for j := range xys { |
| 26 | xys[j].X = center + (rnd.Float64() - 0.5) |
| 27 | xys[j].Y = center + (rnd.Float64() - 0.5) |
| 28 | } |
| 29 | } |
| 30 | |
| 31 | plt := plot.New() |
| 32 | |
| 33 | mean95, err := plotutil.NewErrorPoints(plotutil.MeanAndConf95, pts...) |
| 34 | if err != nil { |
| 35 | panic(err) |
| 36 | } |
| 37 | medMinMax, err := plotutil.NewErrorPoints(plotutil.MedianAndMinMax, pts...) |
| 38 | if err != nil { |
| 39 | panic(err) |
| 40 | } |
| 41 | err = plotutil.AddLinePoints(plt, |
| 42 | "mean and 95% confidence", mean95, |
| 43 | "median and minimum and maximum", medMinMax) |
| 44 | if err != nil { |
| 45 | panic(err) |
| 46 | } |
| 47 | if err := plotutil.AddErrorBars(plt, mean95, medMinMax); err != nil { |
| 48 | panic(err) |
| 49 | } |
| 50 | if err := plotutil.AddScatters(plt, pts[0], pts[1], pts[2], pts[3], pts[4]); err != nil { |
| 51 | panic(err) |
| 52 | } |
| 53 | |
| 54 | err = plt.Save(4, 4, "centroids.png") |
| 55 | if err != nil { |
| 56 | panic(err) |
| 57 | } |
| 58 | } |
nothing calls this directly
no test coverage detected