Producing graphs for documentation

In producing documentation for John Maddock's Math Toolkit, we have used a C++ program to output csv files, with titles in row 1, and data points below, usually several columns, to produce . We then imported this into RJS Graph (version 3.90.10), did a lot of fiddling each time to set the axes, labels, colours, point sizes etc, and finally exported a .ps file. Finally (phew!) we opened with Adobe Photoshop, changed size and saved as .png files (sample attached). These were then referenced from Boost Quickbook to make them appear in the html and pdf. There has got to be a better way!!! Do Boosters have any suggestions/experience on how to automate this process, ideally so that a C++ program directly outputs a .png file. Thanks Paul --- Paul A Bristow Prizet Farmhouse, Kendal, Cumbria UK LA8 8AB +44 1539561830 & SMS, Mobile +44 7714 330204 & SMS pbristow@hetp.u-net.com

Paul A Bristow wrote:
In producing documentation for John Maddock's Math Toolkit, we have used a C++ program to output csv files, with titles in row 1, and data points below, usually several columns, to produce .
We then imported this into RJS Graph (version 3.90.10), did a lot of fiddling each time to set the axes, labels, colours, point sizes etc, and finally exported a .ps file.
Finally (phew!) we opened with Adobe Photoshop, changed size and saved as .png files (sample attached).
These were then referenced from Boost Quickbook to make them appear in the html and pdf.
There has got to be a better way!!!
Do Boosters have any suggestions/experience on how to automate this process, ideally so that a C++ program directly outputs a .png file.
I suggest look at grace. It is a wonderful, free graphing app with high quality output. It can run from the command line, and has various interfaces, such as python interface.

Neal Becker wrote:
Paul A Bristow wrote:
Do Boosters have any suggestions/experience on how to automate this process, ideally so that a C++ program directly outputs a .png file.
I suggest look at grace. It is a wonderful, free graphing app with high quality output. It can run from the command line, and has various interfaces, such as python interface.
_______________________________________________ Unsubscribe & other changes: http://lists.boost.org/mailman/listinfo.cgi/boost
I would concur that grace is a good tool, although I haven't used it enough to know it's quirks. Here's a few of the tools I regularly use to do this sort of stuff: You could look into gnuplot. It's output leaves something to be desired for printed publications, but for online or documentation plots it's not bad. You can still generate your csv files, and write yourself a gnuplot script to automate the production of various file formats (gif, png, jpg, eps, pdf, pnm, etc. etc. etc.) You may also be able to hook into it directly from the c++ if you work hard enough to figure it out ... I've never tried that. You might consider replacing the photoshop step with the ImageMagick toolkit, which can do just about anything to image files that you can think of. You can do your conversion, scaling, and antialiasing in a little commandline script, or through the library. It won't help with the plotting step, however. If you aren't averse to installing a really big package, you could look at the Root framework (root.cern.ch). It isn't exactly the best example of modern C++ best practices, but you can fill out a plot or histogram directly from your C++ library. It's a bit of a steep learning curve, but can make some really pretty plots programmatically. You could even run all your code interactively (I'd compile your library to a so/dll, generate the dictionary, and then load it into the interpreter). I'm sure there are other tools like this that I've used, and if I think of them, I'll let you know. -- ------------------------------------------------------------------------------- Kevin Lynch voice: (617) 353-6025 Physics Department Fax: (617) 353-9393 Boston University office: PRB-361 590 Commonwealth Ave. e-mail: krlynch@bu.edu Boston, MA 02215 USA http://budoe.bu.edu/~krlynch -------------------------------------------------------------------------------

Kevin Lynch said: (by the date of Mon, 08 Jan 2007 13:53:04 -0500)
You could look into gnuplot. It's output leaves something to be desired for printed publications, but for online or documentation plots it's not bad.
not correct. I'm using gnuplot for all my publications in journals, and the quality of graphs is impressive. You just need to fiddle a bit with few options: - if you use .ps output format you get TeX style math formula capabilities in labels - pick some nice font - setting xrange, yrange, titles, xlabel, xlabel. - label placement too, an additional argument after label string can displace the label a bit up or left if it feels 'out of place' and you think that the aligmnment can be better. - setting grid or not - with multiplot you can make several plots in single picture, very useful when I wanted a "top" view in color, and a "cross-section" on the left of 3D data (like topographic map). I have written several programs, that after finishing calculations just dump columns of numbers to file. And one of them even writes a gnuplot script that plots that data, like: plot 'file.dat' using ($1/100):(sin($2)) with lines The best is that scripts allow to make it fully automated. A more sophisticated script only has some variables at the top with comments what they do mean. And the user only changes their values to get the right plot. check that one: set terminal postscript portrait enhanced mono lw 1 "Helvetica" 11 set out 'plot.ps' scale=0.7 set size scale, 0.5*scale set ylabel "{/Symbol D}d" 2 set xlabel "{/Symbol D}L" py=-0.055*scale d=1 L=10 v=0.3 set title "Change of rod diameter {/Symbol D}d assuming d=1, L=10, {/Symbol u}=0.3" plot -d*v*(x/5) title "{/Symbol D}d = - d {/Symbol u} {{/Symbol D}L/L}" \ , -d*(1-(1+(x/5))**(-v)) title "{/Symbol D}d = - d (1-(1+{{/Symbol D}L/L} )^{-{/Symbol u}})" -- Janek Kozicki |

Janek Kozicki said: (by the date of Mon, 8 Jan 2007 20:59:16 +0100)
plot -d*v*(x/5) title "{/Symbol D}d = - d {/Symbol u} {{/Symbol D}L/L}" \ , -d*(1-(1+(x/5))**(-v)) title "{/Symbol D}d = - d (1-(1+{{/Symbol D}L/L} )^{-{/Symbol u}})"
oops line wrapping error plot -d*v*(x/5) title "{/Symbol D}d = - d {/Symbol u} {{/Symbol D}L/L}" \ , -d*(1-(1+(x/5))**(-v)) title "{/Symbol D}d = - d (1-(1+{{/Symbol D}L/L} )^{-{/Symbol u}})" -- Janek Kozicki |

-----Original Message----- From: boost-bounces@lists.boost.org [mailto:boost-bounces@lists.boost.org] On Behalf Of Janek Kozicki Sent: 08 January 2007 19:59 To: boost@lists.boost.org Subject: Re: [boost] Producing graphs for documentation
Kevin Lynch said: (by the date of Mon, 08 Jan 2007 13:53:04 -0500)
You could look into gnuplot.
Looks promising, but tiresome that it doesn't output in .png and so a separate step is needed, which makes full automation difficult. I like the potential to write the gnuplot script from the C++ program (as well as csv data file) and run gnuplot as a Windows Post-build step? But it isn't so nice that I intend to start to re-do all the Math Toolkit graphs. However I will rethink the process in future. Thanks to several responders on this question. Paul --- Paul A Bristow Prizet Farmhouse, Kendal, Cumbria UK LA8 8AB +44 1539561830 & SMS, Mobile +44 7714 330204 & SMS pbristow@hetp.u-net.com

Paul A Bristow wrote:
Kevin Lynch said: (by the date of Mon, 08 Jan 2007 13:53:04 -0500)
You could look into gnuplot.
Looks promising, but tiresome that it doesn't output in .png and so a separate step is needed, which makes full automation difficult.
Oh, but it does! :-) set terminal png <options>
I like the potential to write the gnuplot script from the C++ program (as well as csv data file) and run gnuplot as a Windows Post-build step?
I'm a linux guy ... I wouldn't know how to help you in Windows.
But it isn't so nice that I intend to start to re-do all the Math Toolkit graphs.
I hear you :-) When I read your first email in this thread I thought to myself, "Brave man ... I'd probably just keep doing what I was doing to avoid the pain of migrating" :-)
Paul
Good luck and thanks for the work to date. -- ------------------------------------------------------------------------------- Kevin Lynch voice: (617) 353-6025 Physics Department Fax: (617) 353-9393 Boston University office: PRB-361 590 Commonwealth Ave. e-mail: krlynch@bu.edu Boston, MA 02215 USA http://budoe.bu.edu/~krlynch -------------------------------------------------------------------------------

-----Original Message----- From: boost-bounces@lists.boost.org [mailto:boost-bounces@lists.boost.org] On Behalf Of Kevin Lynch Sent: 09 January 2007 16:27 To: boost@lists.boost.org Subject: Re: [boost] Producing graphs for documentation
Paul A Bristow wrote:
Kevin Lynch said: (by the date of Mon, 08 Jan 2007 13:53:04 -0500)
You could look into gnuplot.
Looks promising, but tiresome that it doesn't output in .png and so a separate step is needed, which makes full automation difficult.
Oh, but it does! :-)
set terminal png <options>
Great! - though the FAQ I read didn't say this - it suggests using Imagemagick.
I like the potential to write the gnuplot script from the C++ program (as well as csv data file) and run gnuplot as a Windows Post-build step?
I'm a linux guy ... I wouldn't know how to help you in Windows.
But it isn't so nice that I intend to start to re-do all the Math Toolkit graphs.
I hear you :-) When I read your first email in this thread I thought to myself, "Brave man ... I'd probably just keep doing what I was doing to avoid the pain of migrating" :-)
Well I have other plotting to do, so I might explore this. Many thanks. Paul PS Comments on the Math Toolkit code and docs will be most welcome in the pre-review period. The text is now so familiar that proof-reading has become difficult for John and I. --- Paul A Bristow Prizet Farmhouse, Kendal, Cumbria UK LA8 8AB +44 1539561830 & SMS, Mobile +44 7714 330204 & SMS pbristow@hetp.u-net.com

In addition to gnuplot, you might try R. It has some great graphics and lots of math/statistical functions as well, which might make creating useful illustrations easy. Of course, you can also write R scripts from any programming language and execute them with the R engine. The graphics devices support postscript and image formats as well as X11 (and perhaps others). See www.r-project.org. Just a thought. Cheers, Brook
participants (6)
-
Brook Milligan
-
Glenn Schrader
-
Janek Kozicki
-
Kevin Lynch
-
Neal Becker
-
Paul A Bristow