Concerning free software, programming, and whatever else I find interesting. Also the blog for my Web site, frigidcode.com.
Quick and dirty plotting with Haskell + Gnuplot
Tags haskell
Assuming you are a Haskeller, you can get a simply x-y plot up very quickly with the gnuplot interface module. This is useful for getting a rough graphical view of some function. Simply...
1. install Gnuplot (through your package manager)
2. cabal install gnuplot
3. use ghci:
Read the lambda as f(x) = sin (x) / x. You can change the x-range from (-20,20) to whatever you prefer. A Gnuplot window will appear, containing the graph.
If you want a plot of a points list:
In both cases the empty list just means use the default plot attributes. Of course, much can be changed from the simple example I gave. See the documentation of the Simple gnuplot module:
http://hackage.haskell.org/packages/...ot-Simple.html
1. install Gnuplot (through your package manager)
2. cabal install gnuplot
3. use ghci:
Code:
$ ghci GHCi, version 7.4.1: http://www.haskell.org/ghc/ :? for help Loading package ghc-prim ... linking ... done. Loading package integer-gmp ... linking ... done. Loading package base ... linking ... done. h> import Graphics.Gnuplot.Simple h> plotFunc [] (linearScale 1000 (-20,20)) (\x -> sin x / x)
If you want a plot of a points list:
Code:
plotList [] [(2,10),(3,15),(4,14),(5,19)]
http://hackage.haskell.org/packages/...ot-Simple.html
Total Comments 0