MCPcopy
hub / github.com/gonum/plot / Save

Method Save

plot.go:525–548  ·  view source on GitHub ↗

Save saves the plot to an image file. The file format is determined by the extension. Supported extensions are: - .eps - .jpg|.jpeg - .pdf - .png - .svg - .tex - .tif|.tiff

(w, h vg.Length, file string)

Source from the content-addressed store, hash-verified

523// - .tex
524// - .tif|.tiff
525func (p *Plot) Save(w, h vg.Length, file string) (err error) {
526 f, err := os.Create(file)
527 if err != nil {
528 return err
529 }
530 defer func() {
531 e := f.Close()
532 if err == nil {
533 err = e
534 }
535 }()
536
537 format := strings.ToLower(filepath.Ext(file))
538 if len(format) != 0 {
539 format = format[1:]
540 }
541 c, err := p.WriterTo(w, h, format)
542 if err != nil {
543 return err
544 }
545
546 _, err = c.WriteTo(f)
547 return err
548}
549
550func init() {
551 font.DefaultCache.Add(liberation.Collection())

Callers 15

TestAxisPaddingFunction · 0.80
ExampleLabelsFunction · 0.80
ExampleContourFunction · 0.80
ExampleBoxPlotFunction · 0.80
ExampleQuartPlotFunction · 0.80
Example_logScaleFunction · 0.80
ExampleSankey_simpleFunction · 0.80
TestFloatPrecisionFunction · 0.80
Example_invertedScaleFunction · 0.80
ExampleErrorsFunction · 0.80

Calls 3

WriterToMethod · 0.95
CloseMethod · 0.80
WriteToMethod · 0.45

Tested by 15

TestAxisPaddingFunction · 0.64
ExampleLabelsFunction · 0.64
ExampleContourFunction · 0.64
ExampleBoxPlotFunction · 0.64
ExampleQuartPlotFunction · 0.64
Example_logScaleFunction · 0.64
ExampleSankey_simpleFunction · 0.64
TestFloatPrecisionFunction · 0.64
Example_invertedScaleFunction · 0.64
ExampleErrorsFunction · 0.64