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

Method Plot

plotter/boxplot.go:332–380  ·  view source on GitHub ↗
(c draw.Canvas, plt *plot.Plot)

Source from the content-addressed store, hash-verified

330type horizBoxPlot struct{ *BoxPlot }
331
332func (b horizBoxPlot) Plot(c draw.Canvas, plt *plot.Plot) {
333 trX, trY := plt.Transforms(&c)
334 y := trY(b.Location)
335 if !c.ContainsY(y) {
336 return
337 }
338 y += b.Offset
339
340 med := trX(b.Median)
341 q1 := trX(b.Quartile1)
342 q3 := trX(b.Quartile3)
343 aLow := trX(b.AdjLow)
344 aHigh := trX(b.AdjHigh)
345
346 pts := []vg.Point{
347 {X: q1, Y: y - b.Width/2},
348 {X: q3, Y: y - b.Width/2},
349 {X: q3, Y: y + b.Width/2},
350 {X: q1, Y: y + b.Width/2},
351 {X: q1, Y: y - b.Width/2 - b.BoxStyle.Width/2},
352 }
353 box := c.ClipLinesX(pts)
354 if b.FillColor != nil {
355 c.FillPolygon(b.FillColor, c.ClipPolygonX(pts))
356 }
357 c.StrokeLines(b.BoxStyle, box...)
358
359 medLine := c.ClipLinesX([]vg.Point{
360 {X: med, Y: y - b.Width/2},
361 {X: med, Y: y + b.Width/2},
362 })
363 c.StrokeLines(b.MedianStyle, medLine...)
364
365 cap := b.CapWidth / 2
366 whisks := c.ClipLinesX(
367 []vg.Point{{X: q3, Y: y}, {X: aHigh, Y: y}},
368 []vg.Point{{X: aHigh, Y: y - cap}, {X: aHigh, Y: y + cap}},
369 []vg.Point{{X: q1, Y: y}, {X: aLow, Y: y}},
370 []vg.Point{{X: aLow, Y: y - cap}, {X: aLow, Y: y + cap}},
371 )
372 c.StrokeLines(b.WhiskerStyle, whisks...)
373
374 for _, out := range b.Outside {
375 x := trX(b.Value(out))
376 if c.ContainsX(x) {
377 c.DrawGlyphNoClip(b.GlyphStyle, vg.Point{X: x, Y: y})
378 }
379 }
380}
381
382// DataRange returns the minimum and maximum x
383// and y values, implementing the plot.DataRanger

Callers

nothing calls this directly

Calls 9

TransformsMethod · 0.80
ContainsYMethod · 0.80
ClipLinesXMethod · 0.80
FillPolygonMethod · 0.80
ClipPolygonXMethod · 0.80
StrokeLinesMethod · 0.80
ContainsXMethod · 0.80
DrawGlyphNoClipMethod · 0.80
ValueMethod · 0.65

Tested by

no test coverage detected