Skip to content

bluenote10/nim-matplotlib

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

19 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Nim Matplotlib

Simple wrapper of matplotlib for Nim.

import matplotlib
import sequtils
import sugar
import random
import lenientops
import math

let xs = toSeq(-100 .. +100)
let ys1 = xs.map(x => x*x + rand(1000.0))
let ys2 = xs.map(x => sin(x.float)*100 + rand(1000.0))

# create a plotting script and add basic plotting instructions
var p = createSinglePlot()
p.plot(xs, ys1, "o-", label := "noisy parabola")
p.plot(xs, ys2, "o-", label := "noisy sine")
p.enableGrid()
p.legend()

# this adds `plt.savefig` for writing the plot to file
p.saveFigure("imgs/basicPlot.png")

# this adds `plt.show()` for interactive plotting
p.show()

# finally: store & run the Python script
p.run()

Output:

basic plot

About

Simple wrapper of matplotlib for Nim

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages