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

Function Example_logScale

plotter/logscale_example_test.go:18–43  ·  view source on GitHub ↗

Example_logScale shows how to create a plot with a log-scale on the Y-axis.

()

Source from the content-addressed store, hash-verified

16
17// Example_logScale shows how to create a plot with a log-scale on the Y-axis.
18func Example_logScale() {
19 p := plot.New()
20 p.Title.Text = "My Plot"
21 p.Y.Scale = plot.LogScale{}
22 p.Y.Tick.Marker = plot.LogTicks{Prec: -1}
23 p.X.Label.Text = "x"
24 p.Y.Label.Text = "f(x)"
25
26 f := plotter.NewFunction(math.Exp)
27 f.XMin = 0.2
28 f.XMax = 10
29 f.Color = color.RGBA{R: 255, A: 255}
30
31 p.Add(f, plotter.NewGrid())
32 p.Legend.Add("exp(x)", f)
33
34 p.X.Min = f.XMin
35 p.X.Max = f.XMax
36 p.Y.Min = math.Exp(f.XMin)
37 p.Y.Max = math.Exp(f.XMax)
38
39 err := p.Save(10*vg.Centimeter, 10*vg.Centimeter, "testdata/logscale.png")
40 if err != nil {
41 log.Panic(err)
42 }
43}
44
45// Example_logScaleWithAutoRescale shows how to create a plot with a log-scale on the Y-axis.
46// The Y-axis is instructed to automatically adapt its range according to

Callers

nothing calls this directly

Calls 5

NewFunction · 0.92
NewFunctionFunction · 0.92
NewGridFunction · 0.92
SaveMethod · 0.80
AddMethod · 0.45

Tested by

no test coverage detected