Boost logo

Boost :

From: Phil Endecott (spam_from_boost_dev_at_[hidden])
Date: 2007-06-13 12:34:17


> For those who have put time or energy into making suggestions for the
> SVG_Plot program, an update (with pretty pictures!) is on the wiki:
> http://svn.boost.org/trac/boost/wiki/soc/2007/VisualizationOfContainers
>
> Feedback / use cases welcome ;).

 From your example on the wiki:

svg_plot my_plot("./image.svg");

my_plot << image_size(500, 200) << x_scale(-7, 9) << draw_axis()
         << plot_range(data1.begin(), data1.end(), blue)
         << plot_range(data2.begin(), data2.end(), green)
         << write();

I would suggest:

svg_plot my_plot;
my_plot.set_image_size(500,200);
my_plot.set_x_scale(-7,9);
my_plot.draw_axis();
my_plot.plot(data1, blue);
my_plot.write("./image.svg");

i.e.
- I don't think that operator overloading of << adds enough to be justified.
- Large numbers of constructor parameters are confusing unless you use
named parameters, which are themselves sufficiently unusual that they
are non-intuitive. I suggest avoiding constructor parameters when
possible and using e.g. set_* methods instead.
- Make it possible to plot an entire container more simply than
specifying both begin and end iterators.

If you feel the need to make the style more compact, it should be
possible to return a reference to the plot and chain methods like this:

my_plot.set_image_size(500,200)
        .set_x_scale(-7,9)
        .draw_axis()
        .plot(data1, blue)
        .write("./image.svg");

- though I haven't tried to do this recently, so maybe I have forgotten
some detail.

You might like to look at how GIL specifies colours, to see if there is
anything that you can re-use. At least, you should make sure that you
don't implement something that is similar-but-not-quite-the-same for
colour names.

The results look great, by the way. I was doing something with Gnuplot
the other night that would have benefited from something like this:

http://chezphil.org/tmp/fanplot.png

I think that a simple wrapper program around your library that can read
and plot CSV files would be most useful.

Regards,

Phil.


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