-
Notifications
You must be signed in to change notification settings - Fork 37
/
Copy pathline_example_test.go
65 lines (54 loc) · 1.18 KB
/
line_example_test.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
// Copyright ©2019 The go-hep Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
package hplot_test
import (
"image/color"
"log"
"go-hep.org/x/hep/hplot"
"gonum.org/v1/plot/vg"
)
// An example of making a vertical-line plot
func ExampleVLine() {
p := hplot.New()
p.Title.Text = "vlines"
p.X.Min = 0
p.X.Max = 10
p.Y.Min = 0
p.Y.Max = 10
var (
left = color.RGBA{B: 255, A: 255}
right = color.RGBA{R: 255, A: 255}
)
p.Add(
hplot.VLine(2.5, left, nil),
hplot.VLine(5, nil, nil),
hplot.VLine(7.5, nil, right),
)
err := p.Save(10*vg.Centimeter, -1, "testdata/vline.png")
if err != nil {
log.Fatalf("error: %+v", err)
}
}
// An example of making a horizontal-line plot
func ExampleHLine() {
p := hplot.New()
p.Title.Text = "hlines"
p.X.Min = 0
p.X.Max = 10
p.Y.Min = 0
p.Y.Max = 10
var (
top = color.RGBA{B: 255, A: 255}
bottom = color.RGBA{R: 255, A: 255}
)
p.Add(
hplot.HLine(2.5, nil, bottom),
hplot.HLine(5, nil, nil),
hplot.HLine(7.5, top, nil),
)
err := p.Save(10*vg.Centimeter, -1, "testdata/hline.png")
if err != nil {
log.Fatalf("error: %+v", err)
}
}