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

Method Plot

plotter/boxplot.go:194–248  ·  view source on GitHub ↗

Plot draws the BoxPlot on Canvas c and Plot plt.

(c draw.Canvas, plt *plot.Plot)

Source from the content-addressed store, hash-verified

192
193// Plot draws the BoxPlot on Canvas c and Plot plt.
194func (b *BoxPlot) Plot(c draw.Canvas, plt *plot.Plot) {
195 if b.Horizontal {
196 b := &horizBoxPlot{b}
197 b.Plot(c, plt)
198 return
199 }
200
201 trX, trY := plt.Transforms(&c)
202 x := trX(b.Location)
203 if !c.ContainsX(x) {
204 return
205 }
206 x += b.Offset
207
208 med := trY(b.Median)
209 q1 := trY(b.Quartile1)
210 q3 := trY(b.Quartile3)
211 aLow := trY(b.AdjLow)
212 aHigh := trY(b.AdjHigh)
213
214 pts := []vg.Point{
215 {X: x - b.Width/2, Y: q1},
216 {X: x - b.Width/2, Y: q3},
217 {X: x + b.Width/2, Y: q3},
218 {X: x + b.Width/2, Y: q1},
219 {X: x - b.Width/2 - b.BoxStyle.Width/2, Y: q1},
220 }
221 box := c.ClipLinesY(pts)
222 if b.FillColor != nil {
223 c.FillPolygon(b.FillColor, c.ClipPolygonY(pts))
224 }
225 c.StrokeLines(b.BoxStyle, box...)
226
227 medLine := c.ClipLinesY([]vg.Point{
228 {X: x - b.Width/2, Y: med},
229 {X: x + b.Width/2, Y: med},
230 })
231 c.StrokeLines(b.MedianStyle, medLine...)
232
233 cap := b.CapWidth / 2
234 whisks := c.ClipLinesY(
235 []vg.Point{{X: x, Y: q3}, {X: x, Y: aHigh}},
236 []vg.Point{{X: x - cap, Y: aHigh}, {X: x + cap, Y: aHigh}},
237 []vg.Point{{X: x, Y: q1}, {X: x, Y: aLow}},
238 []vg.Point{{X: x - cap, Y: aLow}, {X: x + cap, Y: aLow}},
239 )
240 c.StrokeLines(b.WhiskerStyle, whisks...)
241
242 for _, out := range b.Outside {
243 y := trY(b.Value(out))
244 if c.ContainsY(y) {
245 c.DrawGlyphNoClip(b.GlyphStyle, vg.Point{X: x, Y: y})
246 }
247 }
248}
249
250// DataRange returns the minimum and maximum x
251// and y values, implementing the plot.DataRanger

Callers

nothing calls this directly

Calls 9

TransformsMethod · 0.80
ContainsXMethod · 0.80
ClipLinesYMethod · 0.80
FillPolygonMethod · 0.80
ClipPolygonYMethod · 0.80
StrokeLinesMethod · 0.80
ContainsYMethod · 0.80
DrawGlyphNoClipMethod · 0.80
ValueMethod · 0.65

Tested by

no test coverage detected