[Haskell-cafe] Plot Haskell functions in TikZ

Henning Thielemann lemming at henning-thielemann.de
Thu Nov 25 21:41:01 CET 2010


I'd like to draw function graphs in a LaTeX document. I'm using PGF/TikZ 
that allows to interact with gnuplot, but it does not use gnuplot as 
plotter but just for function evaluation. And gnuplot is not very good at 
this, it does not even know 'min' or 'max'.

pgfmanual.pdf says, that in the TikZ you can write in a tikzpicture 
environment:

  --plot[local options] function {gnuplot formula}

This command does two things:
  1. It writes a gnuplot script containing the formula to a 
file like plot-name.gnuplot .
  2. It checks for a data table in plot-name.table and displays the 
contained curve.

Outside of LaTeX, say in a Makefile, you call gnuplot in order to run 
plot-name.gnuplot and receive plot-name.table:

%.table:	%.gnuplot
 	gnuplot $<


Now you can easily guess, what I want to do. I like to write a Haskell 
formula in '--plot' and get a Haskell program, that renders the table. 
The LaTeX macro invocation should look like:

  --plot[local options] haskellfunction {haskell formula}


The Make rule should look like:

%.table:	%.hs
 	runhaskell $<

Has anyone tried to write such a '--plot' command for TikZ?


More information about the Haskell-Cafe mailing list