Last active
September 27, 2018 16:15
-
-
Save owulveryck/90fb6e740122ca6bde9e1ad21c1bede4 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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