func (c *Canvas) Scale(x, y float64) {
	c.wtex(`\pgftransformxscale{%g}`, x)
	c.wtex(`\pgftransformyscale{%g}`, y)
}
Scale implements the vg.Canvas.Scale method.
package vgtex  
import (
	"bufio"
	"bytes"
	"fmt"
	"image"
	"image/color"
	"image/png"
	"io"
	"math"
	"os"
	"strings"
	"time"
	"gonum.org/v1/plot/font"
	"gonum.org/v1/plot/vg"
	"gonum.org/v1/plot/vg/draw"
)
const degPerRadian = 180 / math.Pi
const (
	defaultHeader = `%%%%%% generated by gonum/plot %%%%%%
\documentclass{standalone}
\usepackage{pgf}
\begin{document}
`
	defaultFooter = "\\end{document}\n"
)
func init() {
	draw.RegisterFormat("tex", func(w, h vg.Length) vg.CanvasWriterTo {
		return NewDocument(w, h)
	})
}
type Canvas struct {
	buf   *bytes.Buffer
	w, h  vg.Length
	stack []context
	document bool
	id       int64  
}
type context struct {
	color      color.Color
	dashArray  []vg.Length
	dashOffset vg.Length
	linew      vg.Length
}
func New(w, h vg.Length) *Canvas {
	return newCanvas(w, h, false)
}
func NewDocument(w, h vg.Length) *Canvas {
	return newCanvas(w, h, true)
}
func newCanvas(w, h vg.Length, document bool) *Canvas {
	c := &Canvas{
		buf:      new(bytes.Buffer),
		w:        w,
		h:        h,
		document: document,
		id:       time.Now().UnixNano(),
	}
	if !document {
		c.wtex(`%%%% gonum/plot created for LaTeX/pgf`)
		c.wtex(`%%%% you need to add:`)
		c.wtex(`%%%%   \usepackage{pgf}`)
		c.wtex(`%%%% to your LaTeX document`)
	}
	c.wtex("")
	c.wtex(`\begin{pgfpicture}`)
	c.stack = make([]context, 1)
	vg.Initialize(c)
	return c
}
func (c *Canvas) context() *context {
	return &c.stack[len(c.stack)-1]
}
func (c *Canvas) Size() (w, h vg.Length) {
	return c.w, c.h
}
func (c *Canvas) SetLineWidth(w vg.Length) {
	c.context().linew = w
}
func (c *Canvas) SetLineDash(pattern []vg.Length, offset vg.Length) {
	c.context().dashArray = pattern
	c.context().dashOffset = offset
}
func (c *Canvas) SetColor(clr color.Color) {
	c.context().color = clr
}
func (c *Canvas) Rotate(rad float64) {
	c.wtex(`\pgftransformrotate{%g}`, rad*degPerRadian)
}
func (c *Canvas) Translate(pt vg.Point) {
	c.wtex(`\pgftransformshift{\pgfpoint{%gpt}{%gpt}}`, pt.X, pt.Y)
}