Example_logScale shows how to create a plot with a log-scale on the Y-axis.
()
| 16 | |
| 17 | // Example_logScale shows how to create a plot with a log-scale on the Y-axis. |
| 18 | func 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 |
nothing calls this directly
no test coverage detected