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

Method Draw

plot.go:145–177  ·  view source on GitHub ↗

Draw draws a plot to a draw.Canvas. Plotters are drawn in the order in which they were added to the plot. Plotters that implement the GlyphBoxer interface will have their GlyphBoxes taken into account when padding the plot so that none of their glyphs are clipped.

(c draw.Canvas)

Source from the content-addressed store, hash-verified

143// taken into account when padding the plot so that
144// none of their glyphs are clipped.
145func (p *Plot) Draw(c draw.Canvas) {
146 if p.BackgroundColor != nil {
147 c.SetColor(p.BackgroundColor)
148 c.Fill(c.Rectangle.Path())
149 }
150
151 if p.Title.Text != "" {
152 descent := p.Title.TextStyle.FontExtents().Descent
153 c.FillText(p.Title.TextStyle, vg.Point{X: c.Center().X, Y: c.Max.Y + descent}, p.Title.Text)
154
155 rect := p.Title.TextStyle.Rectangle(p.Title.Text)
156 c.Max.Y -= rect.Size().Y
157 c.Max.Y -= p.Title.Padding
158 }
159
160 p.X.sanitizeRange()
161 x := horizontalAxis{p.X}
162 p.Y.sanitizeRange()
163 y := verticalAxis{p.Y}
164
165 ywidth := y.size()
166
167 xheight := x.size()
168 x.draw(padX(p, draw.Crop(c, ywidth, 0, 0, 0)))
169 y.draw(padY(p, draw.Crop(c, 0, 0, xheight, 0)))
170
171 dataC := padY(p, padX(p, draw.Crop(c, ywidth, 0, xheight, 0)))
172 for _, data := range p.plotters {
173 data.Plot(dataC, p)
174 }
175
176 p.Legend.Draw(draw.Crop(c, ywidth, 0, xheight, 0))
177}
178
179// DataCanvas returns a new draw.Canvas that
180// is the subset of the given draw area into which

Callers 1

WriterToMethod · 0.95

Calls 15

sizeMethod · 0.95
sizeMethod · 0.95
drawMethod · 0.95
drawMethod · 0.95
CropFunction · 0.92
padXFunction · 0.85
padYFunction · 0.85
PathMethod · 0.80
FontExtentsMethod · 0.80
FillTextMethod · 0.80
CenterMethod · 0.80
sanitizeRangeMethod · 0.80

Tested by

no test coverage detected