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

Function ExampleLabels

plotter/labels_example_test.go:18–45  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

16)
17
18func ExampleLabels() {
19 p := plot.New()
20 p.Title.Text = "Labels"
21 p.X.Min = -10
22 p.X.Max = +10
23 p.Y.Min = 0
24 p.Y.Max = +20
25
26 labels, err := plotter.NewLabels(plotter.XYLabels{
27 XYs: []plotter.XY{
28 {X: -5, Y: 5},
29 {X: +5, Y: 5},
30 {X: +5, Y: 15},
31 {X: -5, Y: 15},
32 },
33 Labels: []string{"A", "B", "C", "D"},
34 })
35 if err != nil {
36 log.Fatalf("could not creates labels plotter: %+v", err)
37 }
38
39 p.Add(labels)
40
41 err = p.Save(10*vg.Centimeter, 10*vg.Centimeter, "testdata/labels.png")
42 if err != nil {
43 log.Fatalf("could save plot: %+v", err)
44 }
45}
46
47// ExampleLabels_inCanvasCoordinates shows how to write a label
48// in a plot using the canvas coordinates (instead of the data coordinates.)

Callers

nothing calls this directly

Calls 4

NewFunction · 0.92
NewLabelsFunction · 0.92
SaveMethod · 0.80
AddMethod · 0.45

Tested by

no test coverage detected