MCPcopy Index your code
hub / github.com/gonum/plot / AddErrorBars

Function AddErrorBars

plotutil/add.go:291–329  ·  view source on GitHub ↗

AddErrorBars adds XErrorBars and YErrorBars to a plot. The variadic arguments must be of type plotter.XYer, and must be either a plotter.XErrorer, plotter.YErrorer, or both. Each errorer is added to the plot the color from the Colors function corresponding to its position in the argument list. If

(plt *plot.Plot, vs ...any)

Source from the content-addressed store, hash-verified

289// If an error occurs then none of the plotters are added
290// to the plot, and the error is returned.
291func AddErrorBars(plt *plot.Plot, vs ...any) error {
292 var ps []plot.Plotter
293 for i, v := range vs {
294 added := false
295
296 if xerr, ok := v.(interface {
297 plotter.XYer
298 plotter.XErrorer
299 }); ok {
300 e, err := plotter.NewXErrorBars(xerr)
301 if err != nil {
302 return err
303 }
304 e.Color = Color(i)
305 ps = append(ps, e)
306 added = true
307 }
308
309 if yerr, ok := v.(interface {
310 plotter.XYer
311 plotter.YErrorer
312 }); ok {
313 e, err := plotter.NewYErrorBars(yerr)
314 if err != nil {
315 return err
316 }
317 e.Color = Color(i)
318 ps = append(ps, e)
319 added = true
320 }
321
322 if added {
323 continue
324 }
325 panic(fmt.Sprintf("plotutil: AddErrorBars expects plotter.XErrorer or plotter.YErrorer, got %T", v))
326 }
327 plt.Add(ps...)
328 return nil
329}
330
331// AddXErrorBars adds XErrorBars to a plot.
332// The variadic arguments must be

Callers 2

ExampleErrorPointsFunction · 0.92
Example_errpointsFunction · 0.92

Calls 4

NewXErrorBarsFunction · 0.92
NewYErrorBarsFunction · 0.92
ColorFunction · 0.70
AddMethod · 0.45

Tested by 1

ExampleErrorPointsFunction · 0.74