Boost logo

Boost :

Subject: [boost] Boost.Plot? - Scalable Vector Graphics
From: Paul A. Bristow (pbristow_at_[hidden])
Date: 2009-07-29 10:06:54


Jake Voytko started this library during a 2007 GSoC and I have now expanded
it quite a bit, and begun to use it for my own purposes (including preparing
the plot for the Boost.Math library functions and statistical
distributions).

Before I do any more work on it, I'd appreciate feedback from Boosters on
how useful they think it might be, perhaps as a Boost library?

Although it still has plenty of wrinklies (the calculation of positioning of
titles, legends, axes labels and ticks labels is intricate - to say the
least).

And there are not-a-few nasty warts (this may be the 1st version to throw
away?), so it is in no way review-ready.

But I believe it is working well enough for you to try to use it - and to
give me feedback.

There are of course hundreds of programs for plotting.

What is special about *this* library is that it is in C++ and it has a Boost
license.

It allows you to add just a few lines of code to the end of your C++ program
to take data from any STL container (all or part) and produce a plot as a
Scale Vector Graph (.svg) file. (No need to export data to a file and suck
into Excel ;-) Applause!)

.svg files can be displayed by all good Internet Browsers (and even by IE8
with an Adobe add-in). They are very small but high quality, highly zip
compressible, and equally suitable for printing to viewing on mobiles (only
the features of Tiny SVG are used.).

It takes as little code as

  svg_2d_plot my_plot;
  my_plot
    .plot(map1, "Series 1").stroke_color(blue)
    .plot(map2, "Series 2").stroke_color(red")
    .autoscale(map1);
   my_plot.write("./2d_simple.svg");

but you can have hours of fun trying out hundreds of options to produce some
rather fancy plots.

For your amusement, attached are a few (mostly contrived) examples (with
tasteless garish colors just to highlight the possible options). There are
also lots and lots of other examples. (Note that the 20 plots occupy a mere
30 kb when zipped).

Unusually, there is lots (too much? - 6Mbyte hyperlinked and indexed PDF!)
of documentation, produced using the C++ in QuickBook with Doxygen reference
info and John Maddock's auto-indexing. But there are hundreds of options,
so you will need all the help you can get from tutorials, examples and
indexes.

A novel feature is the built-in handling of an 'uncertain' type (based on
Evan Marshal Manning, C/C++ Users Journal, March 1996 page 29 to 38)
including a double 'most likely' value, an 'uncertainty' estimate, roughly
standard deviation, and an estimate of 'degrees of freedom'. This can be
used to display confidence ellipses and label values "1.23 +-0.01 (21)", for
example. (Of course, you can make much better confidence estimates using
the Boost.Math library).

You can view and can get code from the Boost sandbox

https://svn.boost.org/svn/boost/sandbox/SOC/2007/visualization

Docs are available to build as html and pre-built as pdf (patience - 6
Mbyte!)

https://svn.boost.org/svn/boost/sandbox/SOC/2007/visualization/libs/svg_plot
/doc/pdf/svg_plot.pdf

 or http://tinyurl.com/coqlbg

(or ask if you want zips instead).

Paul

PS Thanks to all those who have offered support, especially John Maddock of
course. It has stress-tested the Quickbook - Doxygen indexing system ;-) I
haven't managed to make the index work perfectly yet and I'm sure it can be
improved.

PPS If I were doing this again, I would not use 'derived' trick to permit
re-use of functions by 1D, 2D and boxplots - it causes the Intellisense of
MS VisualStudio IDE 'Intelligence Circuits' to melt (and sometimes crash -
workaround - delete the .ncb file) making the nice 'goto definition' feature
ineffective and makes debugging difficult (as does the use of set and get
functions). I suspect it makes compile times longer too. There must be a
better way - suggestions welcome.

But I *would* use the chaining feature - I think it makes a very nice syntax
for the user - but tell me what you think.

---
Paul A. Bristow
Prizet Farmhouse
Kendal, UK   LA8 8AB
+44 1539 561830, mobile +44 7714330204
pbristow_at_[hidden]



Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk