Returns a new XErrorBars plotter, or an error on failure. The error values from the XErrorer interface are interpreted as relative to the corresponding X value. The errors for a given X value are computed by taking the absolute value of the error returned by the XErrorer and subtracting the first an
(xerrs interface {
XYer
XErrorer
})
| 146 | // value of the error returned by the XErrorer and subtracting the first and |
| 147 | // adding the second to the X value. |
| 148 | func NewXErrorBars(xerrs interface { |
| 149 | XYer |
| 150 | XErrorer |
| 151 | }) (*XErrorBars, error) { |
| 152 | |
| 153 | errors := make(XErrors, xerrs.Len()) |
| 154 | for i := range errors { |
| 155 | errors[i].Low, errors[i].High = xerrs.XError(i) |
| 156 | if err := CheckFloats(errors[i].Low, errors[i].High); err != nil { |
| 157 | return nil, err |
| 158 | } |
| 159 | } |
| 160 | xys, err := CopyXYs(xerrs) |
| 161 | if err != nil { |
| 162 | return nil, err |
| 163 | } |
| 164 | |
| 165 | return &XErrorBars{ |
| 166 | XYs: xys, |
| 167 | XErrors: errors, |
| 168 | LineStyle: DefaultLineStyle, |
| 169 | CapWidth: DefaultCapWidth, |
| 170 | }, nil |
| 171 | } |
| 172 | |
| 173 | // Plot implements the Plotter interface, drawing labels. |
| 174 | func (e *XErrorBars) Plot(c draw.Canvas, p *plot.Plot) { |