Exemplo n.º 1
0
// Plot implements the plot.Plotter interface.
func (g *Grid) Plot(da plot.DrawArea, plt *plot.Plot) {
	trX, trY := plt.Transforms(&da)

	if g.Vertical.Color == nil {
		goto horiz
	}
	for _, tk := range plt.X.Tick.Marker(plt.X.Min, plt.X.Max) {
		if tk.IsMinor() {
			continue
		}
		x := trX(tk.Value)
		da.StrokeLine2(g.Vertical, x, da.Min.Y, x, da.Min.Y+da.Size.Y)
	}

horiz:
	if g.Horizontal.Color == nil {
		return
	}
	for _, tk := range plt.Y.Tick.Marker(plt.Y.Min, plt.Y.Max) {
		if tk.IsMinor() {
			continue
		}
		y := trY(tk.Value)
		da.StrokeLine2(g.Horizontal, da.Min.X, y, da.Min.X+da.Size.X, y)
	}
}
Exemplo n.º 2
0
// Thumbnail draws a line in the given style down the
// center of a DrawArea as a thumbnail representation
// of the LineStyle of the function.
func (f Function) Thumbnail(da *plot.DrawArea) {
	y := da.Center().Y
	da.StrokeLine2(f.LineStyle, da.Min.X, y, da.Max().X, y)
}
Exemplo n.º 3
0
// Thumbnail the thumbnail for the Line,
// implementing the plot.Thumbnailer interface.
func (pts *Line) Thumbnail(da *plot.DrawArea) {
	y := da.Center().Y
	da.StrokeLine2(pts.LineStyle, da.Min.X, y, da.Max().X, y)
}
Exemplo n.º 4
0
// drawCap draws the cap if it is not clipped.
func (e *YErrorBars) drawCap(da *plot.DrawArea, x, y vg.Length) {
	if !da.Contains(plot.Point{x, y}) {
		return
	}
	da.StrokeLine2(e.LineStyle, x-e.CapWidth/2, y, x+e.CapWidth/2, y)
}