Plot in ASCII in Haskell

2012-02-10

I noticed a funny package on Hackage: textPlot. A neat idea to render simple function plots with ASCII, but it is unusable (doesn't export one of the important functions). A quick fork, and some fixes made it a lot better:

textPlot.next git repository: https://bitbucket.org/jetxee/textplot.next/

Forked package documentation: http://textplot-next-docs.staticloud.com/TextPlot.html

Now it draws axes too. This is how it works:

 ghci> let hat t = 0.5*(1-t**2)*exp(-0.5*t**2)/(sqrt (3*(sqrt pi)))
 ghci> let plot = emptyXYPlot .+ hat .- (-5,5) .| (-0.125,0.25)
 ghci> printPlot plot
        ^
   0.25 +
        |
        |                             ooo
        |                            o   o
        |
        |                           o     o
        |
        |
        |                          o       o
        |
        |                         o         o
        |
        |
        |oooooooooooo            o           o            ooooooooooo
        |            oo                                 oo
        |              oo       o             o       oo
        |                o     o               o     o
        |                 ooo o                 o ooo
        |                    o                   o
 -0.125 +
         +-----------------------------------------------------------+->
         -5.0                                                      5.0

P.S. Yes, I'll send the patches to the upstream.