/Hatlab

Plotting with Gnuplot in Haskell

Primary LanguageHaskellBSD 3-Clause "New" or "Revised" LicenseBSD-3-Clause

Preliminaries

Setup

Install deps using cabal or stack:

cabal install --only-dependencies

or

stack build

Try it

cabal repl or stack ghci then

> :m Hatlab.Plot
> plot [Fun (sin.(pi*)) "sin", Fun (cos.(pi*)) "cos"]

Default plot interval is [-1,1].

example plot

Plotting relations

Hatlab supports plotting of relations on the real numbers. The Hatlab.Relations module defines a small DSL for relations. The supported operations are:

r :: (Double -> Double -> Bool) -> String -> Relation
r defines a basic relation. Some operations on relations are supported:
a .\/. b = a ∪ b
a ./\. b = a ∩ b
c a = complement of a
a .\. b = a minus b
We can plot relations with a similar command as for functions:

> let q = r (\x y -> x == y) "Line"
> let w = r (\x y -> x*x+y*y <= 1) "Disc"
> plot [q, w]

example relation plot