FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
plot/plotter/step_test.go at master · ffhelicopter/plot · GitHub
ffhelicopter
/
plot
Public
forked from
gonum/plot
Notifications
You must be signed in to change notification settings
Fork
0
Star
0
Code
Pull requests
0
Actions
Projects
Security and quality
0
Insights
Additional navigation options
Code
Pull requests
Actions
Projects
Security and quality
Insights
Expand file tree
Breadcrumbs
plot
/
plotter
/
step_test.go
Copy path
More file actions
More file actions
Latest commit
History
History
History
93 lines (78 loc) · 2.23 KB
Breadcrumbs
plot
/
plotter
/
step_test.go
Copy path
File metadata and controls
93 lines (78 loc) · 2.23 KB
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
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
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
// Copyright ©2018 The Gonum 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
plotter_test
import
(
"image/color"
"log"
"testing"
"golang.org/x/exp/rand"
"gonum.org/v1/plot"
"gonum.org/v1/plot/cmpimg"
"gonum.org/v1/plot/plotter"
"gonum.org/v1/plot/vg"
"gonum.org/v1/plot/vg/draw"
)
func
ExampleLine_stepLine
() {
rnd
:=
rand
.
New
(
rand
.
NewSource
(
1
))
// randomPoints returns some random x, y points
// with some interesting kind of trend.
randomPoints
:=
func
(
n
int
,
x
float64
) plotter.
XYs
{
pts
:=
make
(plotter.
XYs
,
n
)
for
i
:=
range
pts
{
pts
[
i
].
X
=
float64
(
i
)
+
x
pts
[
i
].
Y
=
5.
+
10
*
rnd
.
Float64
()
}
return
pts
}
n
:=
4
p
,
err
:=
plot
.
New
()
if
err
!=
nil
{
log
.
Panic
(
err
)
}
p
.
Title
.
Text
=
"Step Example"
p
.
X
.
Label
.
Text
=
"X"
p
.
Y
.
Label
.
Text
=
"Y"
p
.
Add
(
plotter
.
NewGrid
())
stepPre
,
err
:=
plotter
.
NewLine
(
randomPoints
(
n
,
0
))
if
err
!=
nil
{
log
.
Panic
(
err
)
}
stepPre
.
StepStyle
=
plotter
.
PreStep
stepPre
.
FillColor
=
color.
RGBA
{
R
:
196
,
G
:
255
,
B
:
196
,
A
:
255
}
stepMid
,
err
:=
plotter
.
NewLine
(
randomPoints
(
n
,
3.5
))
if
err
!=
nil
{
log
.
Panic
(
err
)
}
stepMid
.
StepStyle
=
plotter
.
MidStep
stepMid
.
LineStyle
=
draw.
LineStyle
{
Color
: color.
RGBA
{
R
:
196
,
B
:
128
,
A
:
255
},
Width
:
vg
.
Points
(
1
)}
stepMidFilled
,
err
:=
plotter
.
NewLine
(
randomPoints
(
n
,
7
))
if
err
!=
nil
{
log
.
Panic
(
err
)
}
stepMidFilled
.
StepStyle
=
plotter
.
MidStep
stepMidFilled
.
LineStyle
=
draw.
LineStyle
{
Color
: color.
RGBA
{
R
:
196
,
B
:
128
,
A
:
255
},
Width
:
vg
.
Points
(
1
)}
stepMidFilled
.
FillColor
=
color.
RGBA
{
R
:
255
,
G
:
196
,
B
:
196
,
A
:
255
}
stepPost
,
err
:=
plotter
.
NewLine
(
randomPoints
(
n
,
10.5
))
if
err
!=
nil
{
log
.
Panic
(
err
)
}
stepPost
.
StepStyle
=
plotter
.
PostStep
stepPost
.
LineStyle
.
Width
=
0
stepPost
.
FillColor
=
color.
RGBA
{
R
:
196
,
G
:
196
,
B
:
255
,
A
:
255
}
p
.
Add
(
stepPre
,
stepMid
,
stepMidFilled
,
stepPost
)
p
.
Legend
.
Add
(
"pre"
,
stepPre
)
p
.
Legend
.
Add
(
"mid"
,
stepMid
)
p
.
Legend
.
Add
(
"midFilled"
,
stepMidFilled
)
p
.
Legend
.
Add
(
"post"
,
stepPost
)
p
.
Legend
.
Top
=
true
p
.
Y
.
Max
=
20
p
.
Y
.
Min
=
0
err
=
p
.
Save
(
200
,
200
,
"testdata/step.png"
)
if
err
!=
nil
{
log
.
Panic
(
err
)
}
}
func
TestStep
(
t
*
testing.
T
) {
cmpimg
.
CheckPlot
(
ExampleLine_stepLine
,
t
,
"step.png"
)
}
Back
|
FazBrowse Home
|
New Git URL