Skip to content

Instantly share code, notes, and snippets.

@owulveryck
Last active September 27, 2018 16:15
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save owulveryck/90fb6e740122ca6bde9e1ad21c1bede4 to your computer and use it in GitHub Desktop.
Save owulveryck/90fb6e740122ca6bde9e1ad21c1bede4 to your computer and use it in GitHub Desktop.
package main
import (
"image/color"
"log"
"math"
"os"
"gonum.org/v1/plot"
"gonum.org/v1/plot/plotter"
)
func main() {
line := plotter.NewFunction(func(x float64) float64 {
return (math.Sqrt(math.Cos(x))*math.Cos(500*x) + math.Sqrt(math.Abs(x)) - 0.4) * math.Pow(3-x*x, 0.1)
})
line.Samples = 5000
line.Color = color.RGBA{R: 255, A: 255}
p, err := plot.New()
if err != nil {
log.Panic(err)
}
p.Add(line)
p.X.Max = 2
p.X.Min = -2
w, err := p.WriterTo(200, 200, "svg")
if err != nil {
log.Panic(err)
}
_, err = w.WriteTo(os.Stdout)
if err != nil {
log.Panic(err)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment