1
2
3
4
5
6
7
8 package plotutil
9
10 import (
11 "image/color"
12
13 "gonum.org/v1/plot/vg"
14 "gonum.org/v1/plot/vg/draw"
15 )
16
17
18 var DefaultColors = SoftColors
19
20 var DarkColors = []color.Color{
21 rgb(238, 46, 47),
22 rgb(0, 140, 72),
23 rgb(24, 90, 169),
24 rgb(244, 125, 35),
25 rgb(102, 44, 145),
26 rgb(162, 29, 33),
27 rgb(180, 56, 148),
28 }
29
30 var SoftColors = []color.Color{
31 rgb(241, 90, 96),
32 rgb(122, 195, 106),
33 rgb(90, 155, 212),
34 rgb(250, 167, 91),
35 rgb(158, 103, 171),
36 rgb(206, 112, 88),
37 rgb(215, 127, 180),
38 }
39
40 func rgb(r, g, b uint8) color.RGBA {
41 return color.RGBA{r, g, b, 255}
42 }
43
44
45
46
47 func Color(i int) color.Color {
48 n := len(DefaultColors)
49 if i < 0 {
50 return DefaultColors[i%n+n]
51 }
52 return DefaultColors[i%n]
53 }
54
55
56
57 var DefaultGlyphShapes = []draw.GlyphDrawer{
58 draw.RingGlyph{},
59 draw.SquareGlyph{},
60 draw.TriangleGlyph{},
61 draw.CrossGlyph{},
62 draw.PlusGlyph{},
63 draw.CircleGlyph{},
64 draw.BoxGlyph{},
65 draw.PyramidGlyph{},
66 }
67
68
69
70
71
72 func Shape(i int) draw.GlyphDrawer {
73 n := len(DefaultGlyphShapes)
74 if i < 0 {
75 return DefaultGlyphShapes[i%n+n]
76 }
77 return DefaultGlyphShapes[i%n]
78 }
79
80
81
82 var DefaultDashes = [][]vg.Length{
83 {},
84
85 {vg.Points(6), vg.Points(2)},
86
87 {vg.Points(2), vg.Points(2)},
88
89 {vg.Points(1), vg.Points(1)},
90
91 {vg.Points(5), vg.Points(2), vg.Points(1), vg.Points(2)},
92
93 {vg.Points(10), vg.Points(2), vg.Points(2), vg.Points(2),
94 vg.Points(2), vg.Points(2), vg.Points(2), vg.Points(2)},
95
96 {vg.Points(10), vg.Points(2), vg.Points(2), vg.Points(2)},
97
98 {vg.Points(5), vg.Points(2), vg.Points(5), vg.Points(2),
99 vg.Points(2), vg.Points(2), vg.Points(2), vg.Points(2)},
100
101 {vg.Points(4), vg.Points(2), vg.Points(4), vg.Points(1),
102 vg.Points(1), vg.Points(1), vg.Points(1), vg.Points(1),
103 vg.Points(1), vg.Points(1)},
104 }
105
106
107
108
109
110 func Dashes(i int) []vg.Length {
111 n := len(DefaultDashes)
112 if i < 0 {
113 return DefaultDashes[i%n+n]
114 }
115 return DefaultDashes[i%n]
116 }
117
View as plain text