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

Function ExampleField

plotter/field_example_test.go:22–53  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

20)
21
22func ExampleField() {
23 f := plotter.NewField(field{
24 r: 17, c: 19,
25 fn: func(x, y float64) plotter.XY {
26 return plotter.XY{
27 X: y,
28 Y: -x,
29 }
30 },
31 })
32 f.LineStyle.Width = 0.2
33
34 p := plot.New()
35 p.Title.Text = "Vector field"
36 p.X.Tick.Marker = integerTicks{}
37 p.Y.Tick.Marker = integerTicks{}
38
39 p.Add(f)
40
41 img := vgimg.New(250, 175)
42 dc := draw.New(img)
43
44 p.Draw(dc)
45 w, err := os.Create("testdata/field.png")
46 if err != nil {
47 log.Panic(err)
48 }
49 png := vgimg.PngCanvas{Canvas: img}
50 if _, err = png.WriteTo(w); err != nil {
51 log.Panic(err)
52 }
53}
54
55func ExampleField_colors() {
56 f := plotter.NewField(field{

Callers

nothing calls this directly

Calls 7

WriteToMethod · 0.95
NewFieldFunction · 0.92
NewFunction · 0.92
NewFunction · 0.92
NewFunction · 0.92
DrawMethod · 0.65
AddMethod · 0.45

Tested by

no test coverage detected