[pstricks] Script for plotting histograms and functions

Hendrik Hoeth hendrik.hoeth at cern.ch
Thu Jul 19 14:13:28 CEST 2007


Hi,

I'm using pstricks to make all the plots for my thesis (danke, Herbert!)
and since there are frequent questions on plotting data or mathematical
functions on this list, I would like to share a small python script
which I use to auto-generate pstricks code and ps or pdf files. I wrote
it specifically for my needs, i.e. lots of histograms and fit functions,
but there are already other people using it in different subjects, and
the script is under constant development.

You can find the script at http://www.linta.de/~hoeth/d0/make_plot/
There are some real-life examples in the "examples" directory. The .dat
files are the input files, the .pdf files are generated by calling
"python make_plot.py --pdf <file>.dat".

There is no documentation (yet?), so have a look at the .dat files --
they are pretty straight forward. The data is tab-separated (!), and the
columns are <lower bin edge> <upper bin edge> <y value> <error>. If you
want to add asymmetric errors to a histogram, just add a fifth column.

To see a list of (almost) all options which you can use in the .dat
files, have a look at histplotter.py. I use it to auto-generate the .dat
files from ROOT histograms [1], but since all the keywords are listed
there, you might find it useful as reference.

Comments are welcome!

Cheers,

    Hendrik

[1] ROOT is a histograming package used in high energy physics, and
    it creates the most ugly looking plots you could imagine:
    http://root.cern.ch/

-- 
Those who give up essential liberties for temporary safety
deserve neither liberty nor safety.   -- Benjamin Franklin



More information about the PSTricks mailing list