MCPcopy Create free account
hub / github.com/gonum/plot / Example

Function Example

palette/moreland/example_test.go:50–140  ·  view source on GitHub ↗

This Example gives examples of plots using the palettes in this package. The output can be found at https://github.com/gonum/plot/blob/master/palette/moreland/testdata/moreland_golden.png.

()

Source from the content-addressed store, hash-verified

48// The output can be found at
49// https://github.com/gonum/plot/blob/master/palette/moreland/testdata/moreland_golden.png.
50func Example() {
51 m := offsetUnitGrid{
52 XOffset: -50,
53 YOffset: -50,
54 Data: mat.NewDense(100, 100, nil),
55 }
56 for i := range 100 {
57 for j := range 100 {
58 x := float64(i-50) / 10
59 y := float64(j-50) / 10
60 v := math.Sin(x*x+y*y) / (x*x + y*y)
61 m.Data.Set(i, j, v)
62 }
63 }
64
65 const (
66 rows = 3
67 cols = 3
68 )
69 c := vgimg.New(vg.Points(800), vg.Points(800))
70 dc := draw.New(c)
71 tiles := draw.Tiles{
72 Rows: rows,
73 Cols: cols,
74 }
75 type paletteHolder struct {
76 name string
77 cmap palette.Palette
78 }
79 palettes := []paletteHolder{
80 {
81 name: "SmoothBlueRed",
82 cmap: moreland.SmoothBlueRed().Palette(255),
83 },
84 {
85 name: "SmoothBlueTan",
86 cmap: moreland.SmoothBlueTan().Palette(255),
87 },
88 {
89 name: "SmoothGreenPurple",
90 cmap: moreland.SmoothGreenPurple().Palette(255),
91 },
92 {
93 name: "SmoothGreenRed",
94 cmap: moreland.SmoothGreenRed().Palette(255),
95 },
96 {
97 name: "SmoothPurpleOrange",
98 cmap: moreland.SmoothPurpleOrange().Palette(255),
99 },
100 {
101 name: "BlackBody",
102 cmap: moreland.BlackBody().Palette(255),
103 },
104 {
105 name: "ExtendedBlackBody",
106 cmap: moreland.ExtendedBlackBody().Palette(255),
107 },

Callers

nothing calls this directly

Calls 15

AtMethod · 0.95
WriteToMethod · 0.95
NewFunction · 0.92
PointsFunction · 0.92
NewFunction · 0.92
SmoothBlueRedFunction · 0.92
SmoothBlueTanFunction · 0.92
SmoothGreenPurpleFunction · 0.92
SmoothGreenRedFunction · 0.92
SmoothPurpleOrangeFunction · 0.92
BlackBodyFunction · 0.92
ExtendedBlackBodyFunction · 0.92

Tested by

no test coverage detected