Plot implements the Plotter interface, drawing labels.
(plt *plot.Plot)
| 108 | |
| 109 | // Plot implements the Plotter interface, drawing labels. |
| 110 | func (e *YErrorBars) Plot(plt *plot.Plot) { |
| 111 | pc := plt.Paint |
| 112 | uc := &pc.UnitContext |
| 113 | |
| 114 | e.CapWidth.ToDots(uc) |
| 115 | cw := 0.5 * e.CapWidth.Dots |
| 116 | nv := len(e.YErrors) |
| 117 | e.PXYs = make(plot.XYs, nv) |
| 118 | e.LineStyle.SetStroke(plt) |
| 119 | for i, err := range e.YErrors { |
| 120 | x := plt.PX(e.XYs[i].X) |
| 121 | ylow := plt.PY(e.XYs[i].Y - math32.Abs(err.Low)) |
| 122 | yhigh := plt.PY(e.XYs[i].Y + math32.Abs(err.High)) |
| 123 | |
| 124 | e.PXYs[i].X = x |
| 125 | e.PXYs[i].Y = yhigh |
| 126 | |
| 127 | pc.MoveTo(x, ylow) |
| 128 | pc.LineTo(x, yhigh) |
| 129 | |
| 130 | pc.MoveTo(x-cw, ylow) |
| 131 | pc.LineTo(x+cw, ylow) |
| 132 | |
| 133 | pc.MoveTo(x-cw, yhigh) |
| 134 | pc.LineTo(x+cw, yhigh) |
| 135 | pc.Stroke() |
| 136 | } |
| 137 | } |
| 138 | |
| 139 | // DataRange implements the plot.DataRanger interface. |
| 140 | func (e *YErrorBars) DataRange() (xmin, xmax, ymin, ymax float32) { |