Boost logo

Boost-Commit :

From: pbristow_at_[hidden]
Date: 2008-06-18 07:18:42


Author: pbristow
Date: 2008-06-18 07:18:41 EDT (Wed, 18 Jun 2008)
New Revision: 46472
URL: http://svn.boost.org/trac/boost/changeset/46472

Log:
Very many changes mostly refactoring ready for separation of definitions to .ipp files,
Text files modified:
   sandbox/SOC/2007/visualization/boost/svg_plot/detail/axis_plot_frame.hpp | 1328 ++++++++++++++++++++++++++-------------
   sandbox/SOC/2007/visualization/boost/svg_plot/quantile.hpp | 2
   sandbox/SOC/2007/visualization/boost/svg_plot/svg_1d_plot.hpp | 255 ++++---
   sandbox/SOC/2007/visualization/boost/svg_plot/svg_2d_plot.hpp | 961 +++++++++++++++++-----------
   sandbox/SOC/2007/visualization/boost/svg_plot/svg_boxplot.hpp | 208 +++++-
   sandbox/SOC/2007/visualization/boost/svg_plot/svg_style.hpp | 418 ++++++++---
   sandbox/SOC/2007/visualization/libs/svg_plot/example/auto_2d_plot.cpp | 2
   sandbox/SOC/2007/visualization/libs/svg_plot/example/demo_2d_bars.cpp | 8
   sandbox/SOC/2007/visualization/libs/svg_plot/test/1d_tests.cpp | 12
   9 files changed, 2041 insertions(+), 1153 deletions(-)

Modified: sandbox/SOC/2007/visualization/boost/svg_plot/detail/axis_plot_frame.hpp
==============================================================================
--- sandbox/SOC/2007/visualization/boost/svg_plot/detail/axis_plot_frame.hpp (original)
+++ sandbox/SOC/2007/visualization/boost/svg_plot/detail/axis_plot_frame.hpp 2008-06-18 07:18:41 EDT (Wed, 18 Jun 2008)
@@ -1180,7 +1180,8 @@
 
 
             // Unclear how to get this uncertainty information into this function,
- // so these arepurely imaginary for now.
+ // so these are purely imaginary for now.
+ // Migh template so can use an uncertain type instead of double?
             double ux = 0.0123;
             double uy = 0.00321;
             double dfx = 23;
@@ -1319,231 +1320,418 @@
           }
         public:
           // Set & get member function Declarations:
- // See svg_fwd.hpp
- // -----------------------------------------------------------------
-
- // Get functions:
- // =========== Image & plot window ==============
- // Derived& image_size(unsigned int x, unsigned int y);
- // unsigned int image_x_size();
- // unsigned int image_y_size()
- // bool plot_window_on()
- // svg_color background_color()
- // svg_color background_border_color()
- // svg_color plot_background_color()
- //
- // std::pair<double, double> plot_window_x()
- // std::pair<double, double> plot_window_y()
-
- // ========= Title & legend ============
- // bool title_on()
- // const std::string title()
- // unsigned int title_font_size()
- // const std::string title_font()
- // svg_color title_color()
- // bool legend_on()
- // const std::string legend_title()
- // svg_color legend_background_color()
- // svg_color legend_border_color()
- // unsigned int legend_title_font_size()
- // ========= Axes & Ticks ============
- // bool x_axis_on()
- // unsigned int x_axis_width()
- // bool x_external_style_on()
- // bool x_ticks_up_on()
- // bool x_ticks_down_on()
- // std::pair<double, double> x_range()
- // double x_minimum()
- // double x_maximum()
- // double x_major_interval()
- // unsigned int x_num_minor__ticks()
- // double x_major_tick()
- // svg_color x_major_tick_color()
- // svg_color x_minor_tick_color()
- // unsigned int x_major_tick_length()
- // unsigned int x_major_tick_width_()
- // unsigned int x_minor_tick_length_()
- // unsigned int x_minor_tick_width_()
- // ========= Labels ============
- // bool x_label_on() // Show X-axis label text.
- // std::string x_label()
- // bool x_label_units_on() //
- // std::string x_label_units() // Show X-axis units text.
- // int x_major_labels_side()
- // svg_color x_label_color()
- // bool axes_on()
- // svg_color x_axis_color()
- // bool y_axis_on()
- // svg_color y_axis_color()
- // std::string y_label()
- // svg_color y_label_color()
- // ========= grid ============
- // bool x_major_grid_on()
- // bool x_minor_grid_on()
- // unsigned int x_major_grid_width()
- // unsigned int x_minor_grid_width()
- // svg_color x_major_grid_color()
- // svg_color x_minor_grid_color()
-
- // Set functions:
-
- //Derived& image_size(unsigned int x, unsigned int y)
- //Derived& image_x_size(unsigned int x);
- //Derived& image_y_size(unsigned int y);
-
- //Derived& title(const std::string& title)
-
- //Derived& document_title(const std::string&);
- //Derived& description(const std::string&);
- //Derived& copyright_date(const std::string&);
- //Derived& copyright_holder(const std::string&);
-
- //Derived& title_font_size(unsigned int size)
- //Derived& legend_title_font_size(unsigned int size)
- //Derived& legend_on(bool cmd)
- //Derived& plot_window_on(bool cmd)
- //Derived& plot_window_x(unsigned int min_x, unsigned int max_x)
- //Derived& plot_window_y(unsigned int min_y, unsigned int max_y)
- //Derived& x_external_style_on(bool cmd)
- //Derived& x_ticks_up_on(bool cmd)
- //Derived& x_ticks_down_on(bool cmd)
- //Derived& x_label_on(bool cmd)
- //Derived& x_label_units_on(bool cmd)
- //Derived& x_major_labels_side(int cmd)
- //Derived& title_on(bool cmd)
- //Derived& x_major_grid_on(bool is)
- //Derived& x_minor_grid_on(bool is)
- //Derived& axes_on(bool is)
- //Derived& x_axis_on(bool is)
- //Derived& y_axis_on(bool is);
- //Derived& title_color(const svg_color& col)
- //Derived& background_color(const svg_color& col)
- //Derived& legend_background_color(const svg_color& col)
- //Derived& legend_border_color(const svg_color& col)
- //Derived& legend_title_font_size(unsigned int size)
- //Derived& legend_color(const svg_color& col)
- //Derived& legend_font_family(const std::string& family)
- //Derived& legend_font_weight(const std::string& weight)
- //Derived& background_border_color(const svg_color& col)
- //Derived& background_border_width(double width)
- //Derived& plot_background_color(const svg_color& col)
- //Derived& x_axis_color(const svg_color& col)
- //Derived& y_axis_color(const svg_color& col)
- //Derived& x_label_color(const svg_color& col)
- //Derived& x_label_color(const svg_color& col)
- //Derived& y_label_color(const svg_color& col)
- //Derived& x_major_tick_color(const svg_color& col)
- //Derived& x_minor_tick_color(const svg_color& col)
- //Derived& x_major_grid_color(const svg_color& col)
- //Derived& x_major_grid_width(unsigned int w)
- //Derived& x_minor_grid_color(const svg_color& col)
- //Derived& x_minor_grid_width(unsigned int w)
- //Derived& x_axis_width(unsigned int width)
- //Derived& x_label(const std::string& str)
- //Derived& x_label_units(const std::string& str)
- //Derived& y_label(const std::string& str)
- //Derived& x_major_interval(double inter)
- //Derived& x_major_tick_length(unsigned int length)
- //Derived& x_major_tick_width_(unsigned int width)
- //Derived& x_minor_tick_length_(unsigned int length)
- //Derived& x_minor_tick_width_(unsigned)
- //Derived& x_major_tick(double d) int width)
- //Derived& x_num_minor_ticks(unsigned int num)
- //Derived& x_range(double min_x, double max_x)
- //Derived& x_minimum(double min_x)
- //Derived& x_maximum(double max_x)
- //Derived& load_stylesheet(const std::string& file)
- // svg& get_svg()
+ // All set functions return derived() == *this to permit chaining,
+ // for example: my_plot.background_color(red).background_border_color(blue)...
 
- // Shapes and glyphs need BOTH fill and stroke to be set.
+ // Shapes and glyphs can have (or may need) BOTH fill and stroke to be set.
           // Both are usually the same in this application.
           // If both are set, stroke is considered 'more important',
           // and so is returned by get functions.
 
+ Derived& image_size(unsigned int x, unsigned int y);
+ unsigned int image_x_size();
+ Derived& image_x_size(unsigned int i);
+ unsigned int image_y_size();
+ Derived& image_y_size(unsigned int i);
+ svg_color background_color();
+ Derived& background_color(const svg_color& col);
+ Derived& background_border_color(const svg_color& col);
+ svg_color background_border_color();
+ Derived& background_border_width(double w);
+ double background_border_width();
+ Derived& description(const std::string d);
+ const std::string& description();
+ Derived& document_title(const std::string d);
+ std::string document_title();
+ Derived& copyright_holder(const std::string d);
+ const std::string copyright_holder();
+ Derived& copyright_date(const std::string d);
+ const std::string copyright_date();
+ Derived& license(std::string repro = "permits",
+ std::string distrib = "permits",
+ std::string attrib = "requires",
+ std::string commercial = "permits",
+ std::string derivative = "permits");
+ bool license_on();
+ Derived& license_on(bool l);
+ bool boost_license_on();
+ Derived& boost_license_on(bool l);
+ const std::string license_reproduction();
+ const std::string license_distribution();
+ const std::string license_attribution();
+ const std::string license_commercialuse();
+ Derived& coord_precision(int digits);
+ int coord_precision();
+ Derived& x_value_precision(int digits);
+ int x_value_precision();
+ Derived& x_value_ioflags(int flags);
+ int x_value_ioflags();
+ Derived& x_labels_strip_e0s(bool cmd);
+ bool y_labels_strip_e0s();
+ Derived& title(const std::string title);
+ const std::string title();
+ Derived& title_font_size(unsigned int i);
+ unsigned int title_font_size();
+ Derived& title_font_family(const std::string& family);
+ const std::string& title_font_family();
+ Derived& title_font_style(const std::string& style);
+ const std::string& title_font_style();
+ Derived& title_font_weight(const std::string& weight);
+ const std::string& title_font_weight();
+ Derived& title_font_stretch(const std::string& stretch);
+ const std::string& title_font_stretch();
+ Derived& title_font_decoration(const std::string& decoration);
+ const std::string& title_font_decoration();
+ Derived& title_font_rotation(rotate_style rotate);
+ int title_font_rotation();
+ Derived& title_font_alignment(align_style alignment);
+ align_style title_font_alignment();
+ // Legend.
+ Derived& legend_width(double width);
+ double legend_width();
+ Derived& legend_title(const std::string title);
+ const std::string legend_title();
+ Derived& legend_font_weight(const std::string& weight);
+ const std::string& legend_font_weight();
+ Derived& legend_font_family(const std::string& family);
+ const std::string& legend_font_family();
+ Derived& legend_title_font_size(unsigned int size);
+ unsigned int legend_title_font_size();
+ Derived& legend_top_left(double x, double y);
+ const std::pair<double, double> legend_top_left();
+ const std::pair<double, double> legend_bottom_right();
+ Derived& legend_lines(bool is);
+ bool legend_lines();
+ Derived& legend_on(bool cmd);
+ bool legend_on();
+ Derived& legend_place(legend_places l);
+ legend_places legend_place();
+ bool legend_outside();
+ Derived& legend_header_font_size(int size);
+ int legend_header_font_size();
+ Derived& plot_window_on(bool cmd);
+ bool plot_window_on();
+ Derived& plot_border_color(const svg_color& col);
+ svg_color plot_border_color();
+ double plot_border_width();
+ Derived& plot_border_width(double w);
+ Derived& image_border_margin(double w);
+ double image_border_margin();
+ Derived& image_border_width(double w);
+ double image_border_width();
+ Derived& plot_window_x(double min_x, double max_x);
+ Derived& plot_window_y(double min_y, double max_y);
+ std::pair<double, double> plot_window_x();
+ double plot_window_x_left();
+ double plot_window_x_right();
+ double plot_window_y_top();
+ double plot_window_y_bottom();
+ std::pair<double, double> plot_window_y();
+ double x_minor_interval();
+ double y_minor_interval();
+ Derived& x_ticks_up_on(bool cmd);
+ bool x_ticks_up_on();
+ Derived& x_ticks_down_on(bool cmd);
+ bool x_ticks_down_on();
+ Derived& x_label_on(bool cmd);
+ bool x_label_on();
+ Derived& x_label_font_size(unsigned int i);
+ unsigned int x_label_font_size();
+ Derived& x_value_font_size(unsigned int i);
+ unsigned int x_value_font_size();
+ Derived& x_label_font_family(const std::string& family);
+ const std::string& x_label_font_family();
+ Derived& x_axis_label_color(const svg_color& col);
+ svg_color x_axis_label_color();
+ Derived& x_axis_value_color(const svg_color& col);
+ svg_color x_axis_value_color();
+ Derived& x_ticks_on_window_or_axis(int cmd);
+ int x_ticks_on_window_or_axis();
+ Derived& x_label_units_on(bool cmd);
+ bool x_label_units_on();
+ Derived& x_major_value_labels_side(int cmd);
+ int x_major_value_labels_side();
+ Derived& x_major_label_rotation(rotate_style rot);
+ rotate_style x_major_label_rotation();
+ Derived& title_on(bool cmd);
+ bool title_on();
+ Derived& x_major_grid_on(bool is);
+ bool x_major_grid_on();
+ Derived& x_minor_grid_on(bool is);
+ bool x_minor_grid_on();
+ Derived& axes_on(bool is);
+ bool axes_on();
+ Derived& x_axis_on(bool is);
+ bool x_axis_on();
+ Derived& y_axis_on(bool is);
+ bool y_axis_on();
+ Derived& title_color(const svg_color& col);
+ svg_color title_color();
+ Derived& legend_color(const svg_color& col);
+ svg_color legend_color();
+ Derived& legend_background_color(const svg_color& col);
+ svg_color legend_background_color();
+ bool legend_box_fill_on();
+ Derived& legend_border_color(const svg_color& col);
+ svg_color legend_border_color();
+ Derived& plot_background_color(const svg_color& col);
+ svg_color plot_background_color();
+ const std::string x_axis_position();
+ Derived& x_axis_color(const svg_color& col);
+ svg_color x_axis_color();
+ Derived& y_axis_color(const svg_color& col);
+ svg_color y_axis_color();
+ Derived& x_label_color(const svg_color& col);
+ Derived& x_label_width(double width);
+ double x_label_width();
+ svg_color x_label_color();
+ Derived& y_label_color(const svg_color& col);
+ svg_color y_label_color();
+ Derived& x_major_tick_color(const svg_color& col);
+ svg_color x_major_tick_color();
+ Derived& x_minor_tick_color(const svg_color& col);
+ svg_color x_minor_tick_color();
+ Derived& x_major_grid_color(const svg_color& col);
+ svg_color x_major_grid_color();
+ Derived& x_major_grid_width(double w);
+ double x_major_grid_width();
+ Derived& x_minor_grid_color(const svg_color& col);
+ svg_color x_minor_grid_color();
+ Derived& x_minor_grid_width(double w);
+ double x_minor_grid_width();
+ Derived& x_axis_width(double width);
+ double x_axis_width();
+ Derived& data_lines_width(double width);
+ double data_lines_width();
+ Derived& x_label(const std::string& str);
+ std::string x_label();
+ Derived& x_label_units(const std::string& str);
+ std::string x_label_units();
+ Derived& y_label(const std::string& str);
+ std::string y_label();
+ Derived& y_label_units(const std::string& str);
+ std::string y_label_units();
+ Derived& x_values_on(bool b);
+ bool x_values_on();
+ Derived& x_values_font_size(unsigned int i);
+ unsigned int x_values_font_size();
+ Derived& x_values_font_family(const std::string& family);
+ const std::string& x_values_font_family();
+ Derived& x_major_interval(double inter);
+ Derived& x_values_color(const svg_color& col);
+ svg_color x_values_color();
+ Derived& x_values_rotation(rotate_style rotate);
+ int x_values_rotation();
+ Derived& x_values_precision(int p);
+ int x_values_precision();
+ Derived& x_values_ioflags(std::ios_base::fmtflags f);
+ std::ios_base::fmtflags x_values_ioflags();
+ Derived& x_plusminus_on(bool b);
+ bool x_plusminus_on();
+ Derived& x_df_on(bool b);
+ bool x_df_on();
+ double x_major_interval();
+ Derived& x_major_tick_length(double length);
+ double x_major_tick_length();
+ Derived& x_major_tick_width(double width);
+ double x_major_tick_width();
+ Derived& x_minor_tick_length(double length);
+ double x_minor_tick_length();
+ Derived& x_minor_tick_width(double width);
+ double x_minor_tick_width();
+ Derived& x_major_tick(double d);
+ double x_major_tick();
+ Derived& x_minor_interval(double interval);
+ Derived& x_num_minor_ticks(unsigned int num);
+ unsigned int x_num_minor_ticks();
+ Derived& x_range(double min_x, double max_x);
+ std::pair<double, double> x_range();
+ Derived& x_min(double min_x);
+ double x_min();
+ Derived& x_max(double x);
+ double x_max();
+ // Set & get autoscale parameters,
+ // Note: all these *MUST* preceed x_autoscale(data) call.
+ bool autoscale_check_limits();
+ Derived& autoscale_check_limits(bool b);
+ bool x_autoscale();
+ Derived& x_autoscale(bool b);
+ bool autoscale();
+ Derived& autoscale(bool b);
+ Derived& x_autoscale(std::pair<double, double> p);
+ template <class T> // T an STL container: array, vector ...
+ Derived& x_autoscale(const T& container); // Whole data series.
+ template <class T> // T an STL container: array, vector ...
+ Derived& x_autoscale(const T& begin, const T& end); // Data series using iterators.
+ Derived& x_with_zero(bool b);
+ bool x_with_zero();
+ Derived& x_min_ticks(int min_ticks);
+ int x_min_ticks();
+ Derived& x_steps(int steps);
+ int x_steps();
+ Derived& x_tight(double tight);
+ double x_tight();
+ // Get results of autoscaling.
+ double x_auto_min_value();
+ double x_auto_max_value();
+ double x_auto_tick_interval();
+ int x_auto_ticks();
+
+ //// Stylesheet.
+ // Removed for now to avoid compile warning in spirit.
 
- // Member functions to set plot options.
- // All return derived() == *this to permit chaining.
+ //Derived& load_stylesheet(const std::string& file)
+ //{
+ // derived().image.load_stylesheet(file);
+ // return derived();
+ //}
 
- //-------------------------------------------------------
+ //// Image info (& identical const version).
 
- Derived& image_size(unsigned int x, unsigned int y)
+ //svg& get_svg()
+ //{
+ // derived()._update_image();
+ // return derived().image;
+ //}
+
+ //const svg& get_svg() const
+ //{
+ // derived()._update_image();
+ // return derived().image;
+ //}
+ }; // template <class Derived> class axis_plot_frame
+
+ // class axis_plot_frame Member function Definitions (for .ipp file):
+
+ template <class Derived>
+ template <class T> // T an STL container: array, vector ...
+ Derived& axis_plot_frame<Derived>::x_autoscale(const T& begin, const T& end)
+ { // Data series using iterators to calculate autoscaled values.
+ scale_axis(begin, end,
+ &derived().x_auto_min_value_, &derived().x_auto_max_value_, &derived().x_auto_tick_interval_, &derived().x_auto_ticks_,
+ derived().autoscale_check_limits_,
+ derived().x_include_zero_, derived().x_tight_, derived().x_min_ticks_, derived().x_steps_);
+
+ derived().x_autoscale_ = true; // Default to use calculated values.
+ return derived();
+ } // x_autoscale(const T& begin, const T& end)
+
+
+ template <class Derived>
+ template <class T> // T an STL container: array, vector ...
+ Derived& axis_plot_frame<Derived>::x_autoscale(const T& container) // Whole data series.
+ { // to use to calculate autoscaled values.
+ //scale_axis(container.begin(), container.end(), // All the container.
+ scale_axis(container, // All the container.
+ &derived().x_auto_min_value_, &derived().x_auto_max_value_, &derived().x_auto_tick_interval_, &derived().x_auto_ticks_,
+ derived().autoscale_check_limits_,
+ derived().x_include_zero_, derived().x_tight_, derived().x_min_ticks_, derived().x_steps_);
+
+ derived().x_autoscale_ = true; // Default to use calculated values.
+ return derived();
+ } // x_autoscale(const T& container)
+
+ template <class Derived>
+ Derived& axis_plot_frame<Derived>::image_size(unsigned int x, unsigned int y)
           { // Might put default sizes here?
             // Check on sanity of these values?
             derived().image.image_size(x, y);
             return derived();
           }
 
- unsigned int image_x_size()
+ template <class Derived>
+ unsigned int axis_plot_frame<Derived>::image_x_size()
           {
             return derived().image.x_size();
           }
 
- Derived& image_x_size(unsigned int i)
+ template <class Derived>
+ Derived& axis_plot_frame<Derived>::image_x_size(unsigned int i)
           {
             derived().image.x_size(i);
             return derived();
           }
 
- unsigned int image_y_size()
+ template <class Derived>
+ unsigned int axis_plot_frame<Derived>::image_y_size()
           {
             return derived().image.y_size();
           }
 
- Derived& image_y_size(unsigned int i)
+ template <class Derived>
+ Derived& axis_plot_frame<Derived>::image_y_size(unsigned int i)
           {
             derived().image.y_size(i);
             return derived();
           }
 
- svg_color background_color()
+ template <class Derived>
+ svg_color axis_plot_frame<Derived>::background_color()
           {
             return derived().image.g(PLOT_BACKGROUND).style().fill_color();
           }
 
- Derived& background_border_color(const svg_color& col)
+ template <class Derived>
+ Derived& axis_plot_frame<Derived>::background_color(const svg_color& col)
+ {
+ derived().image.g(PLOT_BACKGROUND).style().fill_color(col);
+ return derived();
+ }
+
+
+ template <class Derived>
+ Derived& axis_plot_frame<Derived>::background_border_color(const svg_color& col)
           {
             derived().image.g(PLOT_BACKGROUND).style().stroke_color(col);
             return derived();
           }
 
- svg_color background_border_color()
+ template <class Derived>
+ svg_color axis_plot_frame<Derived>::background_border_color()
           {
             return derived().image.g(PLOT_BACKGROUND).style().stroke_color();
           }
 
- Derived& background_border_width(double w)
+ template <class Derived>
+ Derived& axis_plot_frame<Derived>::background_border_width(double w)
           {
             derived().image.g(PLOT_BACKGROUND).style().stroke_width(w);
             return derived();
           }
 
- double background_border_width()
+ template <class Derived>
+ double axis_plot_frame<Derived>::background_border_width()
           {
             return derived().image.g(PLOT_BACKGROUND).style().stroke_width();
           }
 
- Derived& description(const std::string d)
+ template <class Derived>
+ Derived& axis_plot_frame<Derived>::description(const std::string d)
           { // Writes description to the document(for header as <desc>).
             derived().image.description(d);
             return derived();
           }
 
- const std::string& description()
+ template <class Derived>
+ const std::string& axis_plot_frame<Derived>::description()
           { // Gets description of the document(for header as <desc>).
             return derived().image.description();
           }
 
- Derived& document_title(const std::string d)
+ template <class Derived>
+ Derived& axis_plot_frame<Derived>::document_title(const std::string d)
           { // Writes document title to the document(for header as <title>)..
             derived().image.document_title(d);
             return derived();
           }
- std::string document_title()
+ template <class Derived>
+ std::string axis_plot_frame<Derived>::document_title()
           { // Get document title to the document(for header as <title>)..
             return derived().image.document_title();
           }
 
- Derived& copyright_holder(const std::string d)
+ template <class Derived>
+ Derived& axis_plot_frame<Derived>::copyright_holder(const std::string d)
           { // Writes copyright_holder to the document
             // (for header as <!-- SVG Plot Copyright Paul A. Bristow 2007 --> )
             // and as metadata: meta name="copyright" content="Paul A. Bristow" />
@@ -1551,119 +1739,141 @@
             return derived();
           }
 
- const std::string copyright_holder()
+ template <class Derived>
+ const std::string axis_plot_frame<Derived>::copyright_holder()
           { // Get copyright_holder.
             return derived().image.copyright_holder();
           }
 
- Derived& copyright_date(const std::string d)
+ template <class Derived>
+ Derived& axis_plot_frame<Derived>::copyright_date(const std::string d)
           { // Writes copyright_date to the document.
             // and as metadata <meta name="date" content="2007" />
             derived().image.copyright_date(d);
             return derived();
           }
 
- const std::string copyright_date()
+ template <class Derived>
+ const std::string axis_plot_frame<Derived>::copyright_date()
           { // Get copyright_date.
             return derived().image.copyright_date();
           }
 
- Derived& license(std::string repro = "permits",
- std::string distrib = "permits",
- std::string attrib = "requires",
- std::string commercial = "permits",
- std::string derivative = "permits")
+ template <class Derived>
+ Derived& axis_plot_frame<Derived>::license(std::string repro,
+ std::string distrib ,
+ std::string attrib,
+ std::string commercial,
+ std::string derivative)
           { // Might check these are "permits", "requires", or "prohibits"?
             derived().image.license(repro, distrib, attrib, commercial, derivative);
             return derived();
           }
 
- bool license_on()
+ template <class Derived>
+ bool axis_plot_frame<Derived>::license_on()
           {
             return derived().image.license_on();
           }
 
- Derived& license_on(bool l)
+ template <class Derived>
+ Derived& axis_plot_frame<Derived>::license_on(bool l)
           {
             derived().image.license_on(l);
             return derived();
           }
- bool boost_license_on()
+ template <class Derived>
+ bool axis_plot_frame<Derived>::boost_license_on()
           {
             return derived().image.boost_license_one();
           }
 
- Derived& boost_license_on(bool l)
+ template <class Derived>
+ Derived& axis_plot_frame<Derived>::boost_license_on(bool l)
           {
             derived().image.boost_license_on(l);
             return derived();
           }
 
- const std::string license_reproduction()
+ template <class Derived>
+ const std::string axis_plot_frame<Derived>::license_reproduction()
           { // Get copyright_date.
             return derived().image.reproduction();
           }
 
- const std::string license_distribution()
+ template <class Derived>
+ const std::string axis_plot_frame<Derived>::license_distribution()
           { // Get copyright_date.
             return derived().image.distribution();
           }
 
- const std::string license_attribution()
+ template <class Derived>
+ const std::string axis_plot_frame<Derived>::license_attribution()
           { // Get copyright_date.
             return derived().image.attribution();
           }
 
- const std::string license_commercialuse()
+ template <class Derived>
+ const std::string axis_plot_frame<Derived>::license_commercialuse()
           { // Get copyright_date.
             return derived().image.commercialuse();
           }
 
- Derived& coord_precision(int digits)
+
+ template <class Derived>
+ Derived& axis_plot_frame<Derived>::coord_precision(int digits)
           { // Precision of coordinates in decimal digits (default 3).
             derived().image.coord_precision(digits);
             return derived();
           }
 
- int coord_precision()
+ template <class Derived>
+ int axis_plot_frame<Derived>::coord_precision()
           { //
             return derived().image.coord_precision();
           }
 
- Derived& x_value_precision(int digits)
+ template <class Derived>
+ Derived& axis_plot_frame<Derived>::x_value_precision(int digits)
           { // Precision of X tick label values in decimal digits (default 3).
             derived().x_ticks_.value_precision_ = digits;
             return derived();
           }
 
- int x_value_precision()
+ template <class Derived>
+ int axis_plot_frame<Derived>::x_value_precision()
           { //
             return derived().x_ticks_.value_precision_;
           }
 
- Derived& x_value_ioflags(int flags)
+ template <class Derived>
+ Derived& axis_plot_frame<Derived>::x_value_ioflags(int flags)
           { // IO flags of X tick label values (default 0X201).
             derived().x_ticks_.value_ioflags_ = flags;
             return derived();
           }
 
- int x_value_ioflags()
+ template <class Derived>
+ int axis_plot_frame<Derived>::x_value_ioflags()
           { // ALL stream ioflags for control of format of X value labels.
             return derived().x_ticks_.value_ioflags_;
           }
 
- Derived& x_labels_strip_e0s(bool cmd)
+ template <class Derived>
+ Derived& axis_plot_frame<Derived>::x_labels_strip_e0s(bool cmd)
           {
             derived().x_ticks_.strip_e0s_ = cmd;
             return derived();
           }
 
- bool y_labels_strip_e0s()
+ template <class Derived>
+ bool axis_plot_frame<Derived>::y_labels_strip_e0s()
           {
             return derived().x_ticks_.strip_e0s_;
           }
 
- Derived& title(const std::string title)
+ template <class Derived>
+ Derived& axis_plot_frame<Derived>::title(const std::string title)
           { // Plot title. TODO
             // new text parent code pushback
             // effectively concatenates with any existing title.
@@ -1675,157 +1885,186 @@
             return derived();
           }
 
- const std::string title()
+ template <class Derived>
+ const std::string axis_plot_frame<Derived>::title()
           {
             return derived().title_info_.text();
           }
 
- Derived& title_font_size(unsigned int i)
+ template <class Derived>
+ Derived& axis_plot_frame<Derived>::title_font_size(unsigned int i)
           {
             derived().title_info_.style().font_size(i);
             return derived();
           }
 
- unsigned int title_font_size()
+ template <class Derived>
+ unsigned int axis_plot_frame<Derived>::title_font_size()
           {
             return derived().title_info_.style().font_size();
           }
 
- Derived& title_font_family(const std::string& family)
+ template <class Derived>
+ Derived& axis_plot_frame<Derived>::title_font_family(const std::string& family)
           {
             derived().title_info_.style().font_family(family);
             return derived();
           }
 
- const std::string& title_font_family()
+ template <class Derived>
+ const std::string& axis_plot_frame<Derived>::title_font_family()
           {
             return derived().title_info_.style().font_family();
           }
 
- Derived& title_font_style(const std::string& style)
+ template <class Derived>
+ Derived& axis_plot_frame<Derived>::title_font_style(const std::string& style)
           {
             derived().title_info_.style().font_style(style);
             return derived();
           }
 
- const std::string& title_font_style()
+ template <class Derived>
+ const std::string& axis_plot_frame<Derived>::title_font_style()
           {
             return derived().title_info_.style().font_style();
           }
 
- Derived& title_font_weight(const std::string& weight)
+ template <class Derived>
+ Derived& axis_plot_frame<Derived>::title_font_weight(const std::string& weight)
           {
             derived().title_info_.style().font_weight(weight);
             return derived();
           }
 
- const std::string& title_font_weight()
+ template <class Derived>
+ const std::string& axis_plot_frame<Derived>::title_font_weight()
           {
             return derived().title_info_.style().font_weight();
           }
 
- Derived& title_font_stretch(const std::string& stretch)
+ template <class Derived>
+ Derived& axis_plot_frame<Derived>::title_font_stretch(const std::string& stretch)
           {
             derived().title_info_.style().font_stretch(stretch);
             return derived();
           }
 
- const std::string& title_font_stretch()
+ template <class Derived>
+ const std::string& axis_plot_frame<Derived>::title_font_stretch()
           {
             return derived().title_info_.style().font_stretch();
           }
 
- Derived& title_font_decoration(const std::string& decoration)
+ template <class Derived>
+ Derived& axis_plot_frame<Derived>::title_font_decoration(const std::string& decoration)
           {
             derived().title_info_.style().font_decoration(decoration);
             return derived();
           }
 
- const std::string& title_font_decoration()
+ template <class Derived>
+ const std::string& axis_plot_frame<Derived>::title_font_decoration()
           {
             return derived().title_info_.style().font_decoration();
           }
 
- Derived& title_font_rotation(rotate_style rotate)
+ template <class Derived>
+ Derived& axis_plot_frame<Derived>::title_font_rotation(rotate_style rotate)
           { // Degrees (0 to 360).
             derived().title_info_.rotation(rotate);
             return derived();
           }
 
- int title_font_rotation()
+ template <class Derived>
+ int axis_plot_frame<Derived>::title_font_rotation()
           {
             return derived().title_info_.rotation();
           }
 
- Derived& title_font_alignment(align_style alignment)
+ template <class Derived>
+ Derived& axis_plot_frame<Derived>::title_font_alignment(align_style alignment)
           {
             derived().title_info_.alignment(alignment);
             return derived();
           }
 
- align_style title_font_alignment()
+ template <class Derived>
+ align_style axis_plot_frame<Derived>::title_font_alignment()
           {
             return derived().title_info_.alignment();
           }
 
           // Legend.
 
- Derived& legend_width(double width)
+ template <class Derived>
+ Derived& axis_plot_frame<Derived>::legend_width(double width)
           {
             derived().legend_width_ = width;
             return derived();
           }
 
- double legend_width()
+ template <class Derived>
+ double axis_plot_frame<Derived>::legend_width()
           {
             return derived().legend_width_;
           }
 
- Derived& legend_title(const std::string title)
+ template <class Derived>
+ Derived& axis_plot_frame<Derived>::legend_title(const std::string title)
           {
             derived().legend_header_.text(title);
             return derived();
           }
 
- const std::string legend_title()
+ template <class Derived>
+ const std::string axis_plot_frame<Derived>::legend_title()
           {
             return derived().legend_header_.text();
           }
 
- Derived& legend_font_weight(const std::string& weight)
+ template <class Derived>
+ Derived& axis_plot_frame<Derived>::legend_font_weight(const std::string& weight)
           {
             derived().legend_header_.style().font_weight(weight);
             return derived();
           }
 
- const std::string& legend_font_weight()
+ template <class Derived>
+ const std::string& axis_plot_frame<Derived>::legend_font_weight()
           {
             return derived().legend_header_.style().font_weight();
           }
 
- Derived& legend_font_family(const std::string& family)
+ template <class Derived>
+ Derived& axis_plot_frame<Derived>::legend_font_family(const std::string& family)
           {
             derived().legend_header_.style().font_family(family);
             return derived();
           }
 
- const std::string& legend_font_family()
+ template <class Derived>
+ const std::string& axis_plot_frame<Derived>::legend_font_family()
           {
             return derived().legend_header_.style().font_family();
           }
 
- Derived& legend_title_font_size(unsigned int size)
+ template <class Derived>
+ Derived& axis_plot_frame<Derived>::legend_title_font_size(unsigned int size)
           {
             derived().legend_header_.style().font_size(size);
             return derived();
           }
 
- unsigned int legend_title_font_size()
+ template <class Derived>
+ unsigned int axis_plot_frame<Derived>::legend_title_font_size()
           {
             return derived().legend_header_.style().font_size();
           }
 
- Derived& legend_top_left(double x, double y)
+
+ template <class Derived>
+ Derived& axis_plot_frame<Derived>::legend_top_left(double x, double y)
           { // Position of top left of legend box (svg coordinates).
             // Bottom right is controlled by contents, so cannot set it.
             if((x < 0) || (x > derived().image.x_size()) || (y < 0) || (y > derived().image.y_size()))
@@ -1837,7 +2076,8 @@
             return derived();
           }
 
- const std::pair<double, double> legend_top_left()
+ template <class Derived>
+ const std::pair<double, double> axis_plot_frame<Derived>::legend_top_left()
           {// Top left of legend box.
             std::pair<double, double> r;
             r.first = derived().legend_left_;
@@ -1845,7 +2085,8 @@
             return r;
           }
 
- const std::pair<double, double> legend_bottom_right()
+ template <class Derived>
+ const std::pair<double, double> axis_plot_frame<Derived>::legend_bottom_right()
           {// Bottom right of legend box.
             std::pair<double, double> r;
             r.first = derived().legend_right_;
@@ -1853,57 +2094,67 @@
             return r;
           }
 
- Derived& legend_lines(bool is)
+ template <class Derived>
+ Derived& axis_plot_frame<Derived>::legend_lines(bool is)
           { // If legend should include samples of the lines joining data points.
             derived().legend_lines_ = is;
             return derived();
           }
 
- bool legend_lines()
+ template <class Derived>
+ bool axis_plot_frame<Derived>::legend_lines()
           {
             return derived().legend_lines_;
           }
 
- Derived& legend_on(bool cmd)
+ template <class Derived>
+ Derived& axis_plot_frame<Derived>::legend_on(bool cmd)
           {
             derived().legend_on_ = cmd;
             return derived();
           }
 
- bool legend_on()
+ template <class Derived>
+ bool axis_plot_frame<Derived>::legend_on()
           {
             return derived().legend_on_;
           }
 
- Derived& legend_place(legend_places l)
+ template <class Derived>
+ Derived& axis_plot_frame<Derived>::legend_place(legend_places l)
           {
             derived().legend_place_ = l;
             return derived();
           }
 
- legend_places legend_place()
+
+ template <class Derived>
+ legend_places axis_plot_frame<Derived>::legend_place()
           {
             return derived().legend_place_;
           }
 
- bool legend_outside()
+ template <class Derived>
+ bool axis_plot_frame<Derived>::legend_outside()
           {
             return derived().outside_legend_on_;
           }
 
-
- Derived& legend_header_font_size(int size)
+ template <class Derived>
+ Derived& axis_plot_frame<Derived>::legend_header_font_size(int size)
           {
             derived().legend_header_.style().font_size(size);
             return *this;
           }
 
- int legend_header_font_size()
+ template <class Derived>
+ int axis_plot_frame<Derived>::legend_header_font_size()
           {
             return derived().legend_header_.style().font_size();
           }
 
- Derived& plot_window_on(bool cmd)
+ template <class Derived>
+ Derived& axis_plot_frame<Derived>::plot_window_on(bool cmd)
           {
             derived().plot_window_on_ = cmd;
 
@@ -1917,58 +2168,68 @@
             return derived();
           }
 
- bool plot_window_on()
+ template <class Derived>
+ bool axis_plot_frame<Derived>::plot_window_on()
           {
             return derived().plot_window_on_;
           }
 
- Derived& plot_border_color(const svg_color& col)
+ template <class Derived>
+ Derived& axis_plot_frame<Derived>::plot_border_color(const svg_color& col)
           {
             derived().plot_window_border_.stroke_ = col;
             derived().image.g(detail::PLOT_WINDOW_BACKGROUND).style().stroke_color(col);
             return derived();
           }
 
- svg_color plot_border_color()
+ template <class Derived>
+ svg_color axis_plot_frame<Derived>::plot_border_color()
           {
             return derived().image.g(detail::PLOT_WINDOW_BACKGROUND).style().stroke_color();
           }
 
- double plot_border_width()
+ template <class Derived>
+ double axis_plot_frame<Derived>::plot_border_width()
           {
             return derived().image.g(detail::PLOT_WINDOW_BACKGROUND).style().stroke_width();
           }
 
- Derived& plot_border_width(double w)
+ template <class Derived>
+ Derived& axis_plot_frame<Derived>::plot_border_width(double w)
           {
             derived().plot_window_border_.width_ = w;
             derived().image.g(detail::PLOT_WINDOW_BACKGROUND).style().stroke_width(w);
             return derived();
           }
 
- Derived& image_border_margin(double w)
+ template <class Derived>
+ Derived& axis_plot_frame<Derived>::image_border_margin(double w)
           {
             derived().image_border_.margin_ = w;
             return derived();
           }
 
- double image_border_margin()
+ template <class Derived>
+ double axis_plot_frame<Derived>::image_border_margin()
           {
             return derived().image_border_.margin_;
           }
 
- Derived& image_border_width(double w)
+ template <class Derived>
+ Derived& axis_plot_frame<Derived>::image_border_width(double w)
           {
             derived().image_border_.width_ = w;
             return derived();
           }
 
- double image_border_width()
+ template <class Derived>
+ double axis_plot_frame<Derived>::image_border_width()
           {
             return derived().image_border_.width_;
           }
 
- Derived& plot_window_x(double min_x, double max_x)
+ template <class Derived>
+ Derived& axis_plot_frame<Derived>::plot_window_x(double min_x, double max_x)
           { // This is normally calculated from other plot values.
             if(max_x <= min_x)
             {
@@ -1983,7 +2244,8 @@
             return derived();
           }
 
- Derived& plot_window_y(double min_y, double max_y)
+ template <class Derived>
+ Derived& axis_plot_frame<Derived>::plot_window_y(double min_y, double max_y)
           { // This is normally calculated from other plot values.
 
             if(max_y <= min_y)
@@ -1999,7 +2261,8 @@
             return derived();
           }
 
- std::pair<double, double> plot_window_x()
+ template <class Derived>
+ std::pair<double, double> axis_plot_frame<Derived>::plot_window_x()
           {
             std::pair<double, double> r;
             r.first = derived().plot_left_;
@@ -2007,24 +2270,32 @@
             return r;
           }
 
- double plot_window_x_left()
+ template <class Derived>
+ double axis_plot_frame<Derived>::plot_window_x_left()
           {
             return derived().plot_left_;
           }
- double plot_window_x_right()
+ template <class Derived>
+ double axis_plot_frame<Derived>::plot_window_x_right()
           {
             return derived().plot_right_;
           }
- double plot_window_y_top()
+
+ template <class Derived>
+ double axis_plot_frame<Derived>::plot_window_y_top()
           {
             return derived().plot_top_;
           }
- double plot_window_y_bottom()
+
+ template <class Derived>
+ double axis_plot_frame<Derived>::plot_window_y_bottom()
           {
             return derived().plot_bottom_;
           }
 
- std::pair<double, double> plot_window_y()
+
+ template <class Derived>
+ std::pair<double, double> axis_plot_frame<Derived>::plot_window_y()
           {
             std::pair<double, double> r;
             r.first = derived().plot_top_;
@@ -2032,40 +2303,47 @@
             return r;
           }
 
- double x_minor_interval()
+ template <class Derived>
+ double axis_plot_frame<Derived>::x_minor_interval()
           {
             return derived().x_ticks_.minor_interval_; // interval
           }
 
- double y_minor_interval()
+ template <class Derived>
+ double axis_plot_frame<Derived>::y_minor_interval()
           {
             return derived().y_ticks_.minor_interval_; // interval
           }
 
- Derived& x_ticks_up_on(bool cmd)
+ template <class Derived>
+ Derived& axis_plot_frame<Derived>::x_ticks_up_on(bool cmd)
           {
             derived().x_ticks_.up_ticks_on_ = cmd;
             return derived();
           }
 
- bool x_ticks_up_on()
+ template <class Derived>
+ bool axis_plot_frame<Derived>::x_ticks_up_on()
           {
             return derived().x_ticks_.up_ticks_on_;
           }
 
- Derived& x_ticks_down_on(bool cmd)
+ template <class Derived>
+ Derived& axis_plot_frame<Derived>::x_ticks_down_on(bool cmd)
           {
             derived().x_ticks_.down_ticks_on_ = cmd;
             return derived();
           }
 
- bool x_ticks_down_on()
+ template <class Derived>
+ bool axis_plot_frame<Derived>::x_ticks_down_on()
           {
             return derived().x_ticks_.down_ticks_on_;
           }
           // Only need y_ticks_left_on & y_ticks_right_on in 2D
 
- Derived& x_label_on(bool cmd)
+ template <class Derived>
+ Derived& axis_plot_frame<Derived>::x_label_on(bool cmd)
           { // Show X-axis label text, or not.
             // Also switched on by setting label text.
             // (on the assumption that if label text is set, display is also wanted,
@@ -2074,175 +2352,206 @@
             return derived();
           }
 
- bool x_label_on()
+ template <class Derived>
+ bool axis_plot_frame<Derived>::x_label_on()
           {
             return derived().x_axis_.label_on_;
           }
 
- Derived& x_label_font_size(unsigned int i)
+ template <class Derived>
+ Derived& axis_plot_frame<Derived>::x_label_font_size(unsigned int i)
           {
             derived().x_label_info_.style().font_size(i);
             return derived();
           }
 
- unsigned int x_label_font_size()
+ template <class Derived>
+ unsigned int axis_plot_frame<Derived>::x_label_font_size()
           {
             return derived().x_label_info_.style().font_size();
           }
 
- Derived& x_value_font_size(unsigned int i)
+ template <class Derived>
+ Derived& axis_plot_frame<Derived>::x_value_font_size(unsigned int i)
           {
             derived().x_value_value.style().font_size(i);
             return derived();
           }
 
- unsigned int x_value_font_size()
+ template <class Derived>
+ unsigned int axis_plot_frame<Derived>::x_value_font_size()
           {
             return derived().x_value_value.style().font_size();
           }
 
- Derived& x_label_font_family(const std::string& family)
+ template <class Derived>
+ Derived& axis_plot_frame<Derived>::x_label_font_family(const std::string& family)
           {
             derived().x_label_info_.style().font_family(family);
             return derived();
           }
 
- const std::string& x_label_font_family()
+ template <class Derived>
+ const std::string& axis_plot_frame<Derived>::x_label_font_family()
           {
             return derived().x_label_info_.style().font_family();
           }
 
- Derived& x_axis_label_color(const svg_color& col)
+ template <class Derived>
+ Derived& axis_plot_frame<Derived>::x_axis_label_color(const svg_color& col)
           { // Set BOTH stroke and fill to the same color.
             derived().image.g(detail::PLOT_X_LABEL).style().fill_color(col);
             derived().image.g(detail::PLOT_X_LABEL).style().stroke_color(col);
             return *this;
           }
 
- svg_color x_axis_label_color()
+ template <class Derived>
+ svg_color axis_plot_frame<Derived>::x_axis_label_color()
           { // But only return the stroke color.
             return derived().image.g(detail::PLOT_X_LABEL).style().stroke_color();
           }
 
- Derived& x_axis_value_color(const svg_color& col)
+ template <class Derived>
+ Derived& axis_plot_frame<Derived>::x_axis_value_color(const svg_color& col)
           { // Set BOTH stroke and fill to the same color.
             derived().image.g(detail::PLOT_VALUE_LABELS).style().fill_color(col);
             derived().image.g(detail::PLOT_VALUE_LABELS).style().stroke_color(col);
             return *this;
           }
 
- svg_color x_axis_value_color()
+ template <class Derived>
+ svg_color axis_plot_frame<Derived>::x_axis_value_color()
           { // But only return the stroke color.
             return derived().image.g(detail::PLOT_VALUE_LABELS).style().stroke_color();
           }
 
- Derived& x_ticks_on_window_or_axis(int cmd)
+ template <class Derived>
+ Derived& axis_plot_frame<Derived>::x_ticks_on_window_or_axis(int cmd)
           { // External style, top = +1, bottom = -1 (default).
             derived().x_ticks_.ticks_on_window_or_axis_ = cmd;
             return derived();
           }
 
- int x_ticks_on_window_or_axis()
+ template <class Derived>
+ int axis_plot_frame<Derived>::x_ticks_on_window_or_axis()
           { // External style = true.
             return derived().x_ticks_.ticks_on_window_or_axis_;
           }
 
- Derived& x_label_units_on(bool cmd)
+ template <class Derived>
+ Derived& axis_plot_frame<Derived>::x_label_units_on(bool cmd)
           {
             derived().x_axis_.label_units_on_ = cmd;
             return derived();
           }
 
- bool x_label_units_on()
+ template <class Derived>
+ bool axis_plot_frame<Derived>::x_label_units_on()
           {
             return derived().x_axis_.label_units_on_;
           }
 
- Derived& x_major_value_labels_side(int cmd)
+ template <class Derived>
+ Derived& axis_plot_frame<Derived>::x_major_value_labels_side(int cmd)
           {
             derived().x_ticks_.major_value_labels_side_ = cmd;
             return derived();
           }
 
- int x_major_value_labels_side()
+ template <class Derived>
+ int axis_plot_frame<Derived>::x_major_value_labels_side()
           {
             return derived().x_ticks_.major_value_labels_side_;
           }
 
- Derived& x_major_label_rotation(rotate_style rot)
+ template <class Derived>
+ Derived& axis_plot_frame<Derived>::x_major_label_rotation(rotate_style rot)
           {
             derived().x_ticks_.label_rotation_ = rot;
             return derived();
           }
 
- rotate_style x_major_label_rotation()
+ template <class Derived>
+ rotate_style axis_plot_frame<Derived>::x_major_label_rotation()
           {
             return derived().x_ticks_.label_rotation_;
           }
 
- Derived& title_on(bool cmd)
+ template <class Derived>
+ Derived& axis_plot_frame<Derived>::title_on(bool cmd)
           {
             derived().title_on_ = cmd;
             return derived();
           }
 
- bool title_on()
+ template <class Derived>
+ bool axis_plot_frame<Derived>::title_on()
           {
             return derived().title_on_;
           }
 
- Derived& x_major_grid_on(bool is)
+ template <class Derived>
+ Derived& axis_plot_frame<Derived>::x_major_grid_on(bool is)
           {
             derived().x_ticks_.major_grid_on_ = is;
             return derived();
           }
 
- bool x_major_grid_on()
+ template <class Derived>
+ bool axis_plot_frame<Derived>::x_major_grid_on()
           {
             return derived().x_ticks_.major_grid_on_;
           }
 
- Derived& x_minor_grid_on(bool is)
+ template <class Derived>
+ Derived& axis_plot_frame<Derived>::x_minor_grid_on(bool is)
           {
             derived().x_ticks_.minor_grid_on_ = is;
             return derived();
           }
 
- bool x_minor_grid_on()
+ template <class Derived>
+ bool axis_plot_frame<Derived>::x_minor_grid_on()
           {
             return derived().x_ticks_.minor_grid_on_;
           }
 
- Derived& axes_on(bool is)
+ template <class Derived>
+ Derived& axis_plot_frame<Derived>::axes_on(bool is)
           { // Draw *both* x and y axes (note plural).
             derived().x_axis_.axis_line_on_ = is;
             derived().y_axis_.axis_line_on_ = is; // Unsuitable for 1D?
             return derived();
           }
 
- bool axes_on()
+ template <class Derived>
+ bool axis_plot_frame<Derived>::axes_on()
           { // Used X in preference to Y for 1D, but now require *both* x and y axis on.
             return derived().x_axis_.axis_line_on_ && derived().y_axis_.axis_line_on_;
           }
 
- Derived& x_axis_on(bool is)
+ template <class Derived>
+ Derived& axis_plot_frame<Derived>::x_axis_on(bool is)
           { // Draw a horizontal x_axis_ line.
             derived().x_axis_.axis_line_on_ = is;
             return derived();
           }
 
- bool x_axis_on()
+ template <class Derived>
+ bool axis_plot_frame<Derived>::x_axis_on()
           { // Use X in preference to Y for 1D
             return derived().x_axis_.axis_line_on_;
           }
 
- Derived& y_axis_on(bool is)
+ template <class Derived>
+ Derived& axis_plot_frame<Derived>::y_axis_on(bool is)
           {// Draw a vertical y_axis_ line.
             derived().y_axis_.axis_line_on_ = is;
             return derived();
           }
 
- bool y_axis_on()
+ template <class Derived>
+ bool axis_plot_frame<Derived>::y_axis_on()
           { // Should be always false for 1D.
             return derived().y_axis_.axis_line_on_;
           }
@@ -2250,7 +2559,8 @@
           // enums like PLOT_TITLE provide a std:string like "title"
           // colors .stroke_color, .stroke_width and font are set in the appropriate g_element.
 
- Derived& title_color(const svg_color& col)
+ template <class Derived>
+ Derived& axis_plot_frame<Derived>::title_color(const svg_color& col)
           { // Function title_color could set both fill (middle) and stroke (outside),
             // but just setting fill if simplest,
             // but does not allow separate inside & outside colors.
@@ -2259,7 +2569,8 @@
             return derived();
           }
 
- svg_color title_color()
+ template <class Derived>
+ svg_color axis_plot_frame<Derived>::title_color()
           { // Function title_color could get either fill and stroke,
             // return derived().image.g(PLOT_TITLE).style().stroke_color();
             return derived().image.g(PLOT_TITLE).style().fill_color();
@@ -2273,85 +2584,87 @@
           // return derived();
           //}
 
+ //Derived& legend_font_width(double width)
+ //{ // width of text is effectively the boldness.
+ // derived().image.g(PLOT_LEGEND_TEXT).style().stroke_width(width);
+ // return derived();
+ //}
+
+ //double legend_font_width()
+ //{ // Probably not useful at present (se above).
+ // return derived().image.g(PLOT_LEGEND_TEXT).style().stroke_width();
+ //}
           //double title_font_width()
           //{
           // return derived().image.g(PLOT_TITLE).style().stroke_width();
           //}
 
- Derived& legend_color(const svg_color& col)
+ template <class Derived>
+ Derived& axis_plot_frame<Derived>::legend_color(const svg_color& col)
           {
             // derived().image.g(PLOT_LEGEND_TEXT).style().stroke_color(col);
             derived().image.g(PLOT_LEGEND_TEXT).style().fill_color(col);
             return derived();
           }
 
- svg_color legend_color()
+ template <class Derived>
+ svg_color axis_plot_frame<Derived>::legend_color()
           { // Function legend_color sets only stroke, assuming that 'filled' text is not being used.
             // (It produces much lower quality fonts on some browsers).
             return derived().image.g(PLOT_LEGEND_TEXT).style().fill_color();
             // return derived().image.g(PLOT_LEGEND_TEXT).style().stroke_color();
           }
 
- //Derived& legend_font_width(double width)
- //{ // width of text is effectively the boldness.
- // derived().image.g(PLOT_LEGEND_TEXT).style().stroke_width(width);
- // return derived();
- //}
-
- //double legend_font_width()
- //{ // Probably not useful at present (se above).
- // return derived().image.g(PLOT_LEGEND_TEXT).style().stroke_width();
- //}
-
- Derived& background_color(const svg_color& col)
- { // plot background
- derived().plot_window_border_.fill(col);
- derived().image.g(PLOT_BACKGROUND).style().fill_color(col);
- return derived();
- }
-
- Derived& legend_background_color(const svg_color& col)
+ template <class Derived>
+ Derived& axis_plot_frame<Derived>::legend_background_color(const svg_color& col)
           {
             derived().legend_box_.fill(col);
             derived().image.g(PLOT_LEGEND_BACKGROUND).style().fill_color(col);
             return derived();
           }
 
- svg_color legend_background_color()
+ template <class Derived>
+ svg_color axis_plot_frame<Derived>::legend_background_color()
           {
             return derived().image.g(PLOT_LEGEND_BACKGROUND).style().fill_color();
           }
 
- bool legend_box_fill_on()
+ template <class Derived>
+ bool axis_plot_frame<Derived>::legend_box_fill_on()
           {
             return derived().legend_box_.fill_on();
           }
 
- Derived& legend_border_color(const svg_color& col)
+ template <class Derived>
+ Derived& axis_plot_frame<Derived>::legend_border_color(const svg_color& col)
           {
             derived().legend_box_.stroke(col);
             derived().image.g(PLOT_LEGEND_BACKGROUND).style().stroke_color(col);
             return derived();
           }
 
- svg_color legend_border_color()
+ template <class Derived>
+ svg_color axis_plot_frame<Derived>::legend_border_color()
           {
             return derived().legend_box_.stroke();
             // return derived().image.g(PLOT_LEGEND_BACKGROUND).style().stroke_color();
           }
 
- Derived& plot_background_color(const svg_color& col)
+ template <class Derived>
+ Derived& axis_plot_frame<Derived>::plot_background_color(const svg_color& col)
           {
             derived().image.g(PLOT_WINDOW_BACKGROUND).style().fill_color(col);
             return derived();
           }
 
- svg_color plot_background_color()
+ template <class Derived>
+ svg_color axis_plot_frame<Derived>::plot_background_color()
           {
             return derived().image.g(PLOT_WINDOW_BACKGROUND).style().fill_color();
           }
 
- const std::string x_axis_position()
+ template <class Derived>
+ const std::string axis_plot_frame<Derived>::x_axis_position()
           { // Return the position of the X-axis.
             switch(derived().x_axis_position_)
             {
@@ -2366,153 +2679,183 @@
             }
           }
 
- Derived& x_axis_color(const svg_color& col)
+ template <class Derived>
+ Derived& axis_plot_frame<Derived>::x_axis_color(const svg_color& col)
           { // Note only stroke color is set.
             derived().image.g(PLOT_X_AXIS).style().stroke_color(col);
             return derived();
           }
 
- svg_color x_axis_color()
+ template <class Derived>
+ svg_color axis_plot_frame<Derived>::x_axis_color()
           {
             return derived().image.g(PLOT_X_AXIS).style().stroke_color();
           }
 
- Derived& y_axis_color(const svg_color& col)
+ template <class Derived>
+ Derived& axis_plot_frame<Derived>::y_axis_color(const svg_color& col)
           {
             derived().image.g(PLOT_Y_AXIS).style().stroke_color(col);
             return derived();
           }
 
- svg_color y_axis_color()
+ template <class Derived>
+ svg_color axis_plot_frame<Derived>::y_axis_color()
           {
             return derived().image.g(PLOT_Y_AXIS).style().stroke_color();
           }
 
- Derived& x_label_color(const svg_color& col)
+ template <class Derived>
+ Derived& axis_plot_frame<Derived>::x_label_color(const svg_color& col)
           { // add fill as well PAB Oct 07
             derived().image.g(PLOT_X_LABEL).style().fill_color(col);
             derived().image.g(PLOT_X_LABEL).style().stroke_color(col);
             return derived();
           }
 
- // Removed until browsers implement better.
- //Derived& x_label_width(double width)
- //{ // width of text is effectively the boldness.
- // derived().image.g(PLOT_X_LABEL).style().stroke_width(width);
- // return derived();
- //}
+ // Browsers could implement better.
+ template <class Derived>
+ Derived& axis_plot_frame<Derived>::x_label_width(double width)
+ { // width of text is effectively the boldness.
+ derived().image.g(PLOT_X_LABEL).style().stroke_width(width);
+ return derived();
+ }
 
- //double x_label_width()
- //{
- // return derived().image.g(PLOT_X_LABEL).style().stroke_width();
- //}
+ template <class Derived>
+ double axis_plot_frame<Derived>::x_label_width()
+ {
+ return derived().image.g(PLOT_X_LABEL).style().stroke_width();
+ }
 
- svg_color x_label_color()
+ template <class Derived>
+ svg_color axis_plot_frame<Derived>::x_label_color()
           {
             return derived().image.g(PLOT_X_LABEL).style().fill_color();
           }
 
- Derived& y_label_color(const svg_color& col)
+ template <class Derived>
+ Derived& axis_plot_frame<Derived>::y_label_color(const svg_color& col)
           {
             derived().image.g(PLOT_Y_LABEL).style().fill_color(col);
             derived().image.g(PLOT_Y_LABEL).style().stroke_color(col);
             return derived();
           }
 
- svg_color y_label_color()
+ template <class Derived>
+ svg_color axis_plot_frame<Derived>::y_label_color()
           {
             return derived().image.g(PLOT_Y_LABEL).style().fill_color();
           }
 
- Derived& x_major_tick_color(const svg_color& col)
+ template <class Derived>
+ Derived& axis_plot_frame<Derived>::x_major_tick_color(const svg_color& col)
           {
             derived().image.g(PLOT_X_MAJOR_TICKS).style().stroke_color(col);
             return derived();
           }
 
- svg_color x_major_tick_color()
+
+ template <class Derived>
+ svg_color axis_plot_frame<Derived>::x_major_tick_color()
           {
             return derived().image.g(PLOT_X_MAJOR_TICKS).style().stroke_color();
           }
 
- Derived& x_minor_tick_color(const svg_color& col)
+ template <class Derived>
+ Derived& axis_plot_frame<Derived>::x_minor_tick_color(const svg_color& col)
           {
             derived().image.g(PLOT_X_MINOR_TICKS).style().stroke_color(col);
             return derived();
           }
 
- svg_color x_minor_tick_color()
+ template <class Derived>
+ svg_color axis_plot_frame<Derived>::x_minor_tick_color()
           {
             return derived().image.g(PLOT_X_MINOR_TICKS).style().stroke_color();
           }
 
- Derived& x_major_grid_color(const svg_color& col)
+ template <class Derived>
+ Derived& axis_plot_frame<Derived>::x_major_grid_color(const svg_color& col)
           {
             derived().image.g(PLOT_X_MAJOR_GRID).style().stroke_color(col);
             return derived();
           }
 
- svg_color x_major_grid_color()
+ template <class Derived>
+ svg_color axis_plot_frame<Derived>::x_major_grid_color()
           {
             return derived().image.g(PLOT_X_MAJOR_GRID).style().stroke_color();
           }
 
- Derived& x_major_grid_width(double w)
+ template <class Derived>
+ Derived& axis_plot_frame<Derived>::x_major_grid_width(double w)
           {
             derived().image.g(PLOT_X_MAJOR_GRID).style().stroke_width(w);
             return derived();
           }
 
- double x_major_grid_width()
+ template <class Derived>
+ double axis_plot_frame<Derived>::x_major_grid_width()
           {
             return derived().image.g(PLOT_X_MAJOR_GRID).style().stroke_width();
           }
 
- Derived& x_minor_grid_color(const svg_color& col)
+
+ template <class Derived>
+ Derived& axis_plot_frame<Derived>::x_minor_grid_color(const svg_color& col)
           {
             derived().image.g(PLOT_X_MINOR_GRID).style().stroke_color(col);
             return derived();
           }
 
- svg_color x_minor_grid_color()
+ template <class Derived>
+ svg_color axis_plot_frame<Derived>::x_minor_grid_color()
           {
             return derived().image.g(PLOT_X_MINOR_GRID).style().stroke_color();
           }
 
- Derived& x_minor_grid_width(double w)
+ template <class Derived>
+ Derived& axis_plot_frame<Derived>::x_minor_grid_width(double w)
           {
             derived().image.g(PLOT_X_MINOR_GRID).style().stroke_width(w);
             return derived();
           }
 
- double x_minor_grid_width()
+ template <class Derived>
+ double axis_plot_frame<Derived>::x_minor_grid_width()
           {
             return derived().image.g(PLOT_X_MINOR_GRID).style().stroke_width();
           }
 
- Derived& x_axis_width(double width)
+ template <class Derived>
+ Derived& axis_plot_frame<Derived>::x_axis_width(double width)
           {
             derived().image.g(PLOT_X_AXIS).style().stroke_width(width);
             return derived();
           }
 
- double x_axis_width()
+ template <class Derived>
+ double axis_plot_frame<Derived>::x_axis_width()
           {
             return derived().image.g(PLOT_X_AXIS).style().stroke_width();
           }
 
- Derived& data_lines_width(double width)
+ template <class Derived>
+ Derived& axis_plot_frame<Derived>::data_lines_width(double width)
           {
             derived().image.g(PLOT_DATA_LINES).style().stroke_width(width);
             return derived();
           }
 
- double data_lines_width()
+ template <class Derived>
+ double axis_plot_frame<Derived>::data_lines_width()
           {
             return derived().image.g(PLOT_DATA_LINES).style().stroke_width();
           }
 
- Derived& x_label(const std::string& str)
+
+ template <class Derived>
+ Derived& axis_plot_frame<Derived>::x_label(const std::string& str)
           {
             derived().x_label_info_.text(str);
             derived().x_axis_.label_on_ = true; // Assume want x_label string displayed.
@@ -2520,88 +2863,103 @@
             return derived();
           }
 
- std::string x_label()
+ template <class Derived>
+ std::string axis_plot_frame<Derived>::x_label()
           {
             return derived().x_label_info_.text();
           }
 
- Derived& x_label_units(const std::string& str)
+ template <class Derived>
+ Derived& axis_plot_frame<Derived>::x_label_units(const std::string& str)
           {
             derived().x_units_info_.text(str);
             derived().x_axis_.label_on_ = true; // Assume want x_label string displayed.
             return derived();
           }
 
- std::string x_label_units()
+ template <class Derived>
+ std::string axis_plot_frame<Derived>::x_label_units()
           {
             return derived().x_units_info_.text();
           }
 
           // y_label not needed in 1D.
- Derived& y_label(const std::string& str)
+ template <class Derived>
+ Derived& axis_plot_frame<Derived>::y_label(const std::string& str)
           {
             derived().y_label_info_.text(str);
             derived().y_axis_.label_on_ = true; // Assume want y_label string displayed.
             return derived();
           }
 
- std::string y_label()
+ template <class Derived>
+ std::string axis_plot_frame<Derived>::y_label()
           {
             return derived().y_label_info_.text();
           }
 
- Derived& y_label_units(const std::string& str)
+ template <class Derived>
+ Derived& axis_plot_frame<Derived>::y_label_units(const std::string& str)
           {
             derived().y_units_info_.text(str);
             derived().y_axis_.label_on_ = true; // Assume want y_label string displayed.
             return derived();
           }
 
- std::string y_label_units()
+ template <class Derived>
+ std::string axis_plot_frame<Derived>::y_label_units()
           {
             return derived().y_units_info_.text();
           }
-
- Derived& x_values_on(bool b)
+
+ template <class Derived>
+ Derived& axis_plot_frame<Derived>::x_values_on(bool b)
           { // Show values near data points.
             derived().x_values_on_ = b;
             return derived();
           }
 
- bool x_values_on()
+ template <class Derived>
+ bool axis_plot_frame<Derived>::x_values_on()
           { // Label data points with X values.
             return derived().x_values_on_;
           }
 
- Derived& x_values_font_size(unsigned int i)
+ template <class Derived>
+ Derived& axis_plot_frame<Derived>::x_values_font_size(unsigned int i)
           {
             derived().x_values_style_.values_text_style_.font_size(i);
             return derived();
           }
 
- unsigned int x_values_font_size()
+ template <class Derived>
+ unsigned int axis_plot_frame<Derived>::x_values_font_size()
           {
             return derived().x_values_style_.values_text_style_.font_size();
           }
 
- Derived& x_values_font_family(const std::string& family)
+ template <class Derived>
+ Derived& axis_plot_frame<Derived>::x_values_font_family(const std::string& family)
           {
             derived().x_values_style_.values_text_style_.font_family(family);
             return derived();
           }
 
- const std::string& x_values_font_family()
+ template <class Derived>
+ const std::string& axis_plot_frame<Derived>::x_values_font_family()
           {
             return derived().x_values_style_.values_text_style_.font_family();
           }
 
- Derived& x_major_interval(double inter)
+ template <class Derived>
+ Derived& axis_plot_frame<Derived>::x_major_interval(double inter)
           {
             derived().x_ticks_.major_interval_ = inter;
             return derived();
           }
 
- Derived& x_values_color(const svg_color& col)
+ template <class Derived>
+ Derived& axis_plot_frame<Derived>::x_values_color(const svg_color& col)
           { // Function could set both fill (middle) and stroke (outside),
             // but just setting fill if simplest,
             // but does not allow separate inside & outside colors.
@@ -2610,146 +2968,174 @@
             return derived();
           }
 
- svg_color x_values_color()
+ template <class Derived>
+ svg_color axis_plot_frame<Derived>::x_values_color()
           { // Function could get either fill and stroke,
             // return derived().image.g(PLOT_X_POINT_VALUES).style().stroke_color();
             return derived().image.g(PLOT_X_POINT_VALUES).style().fill_color();
           }
 
- Derived& x_values_rotation(rotate_style rotate)
+ template <class Derived>
+ Derived& axis_plot_frame<Derived>::x_values_rotation(rotate_style rotate)
           { // Degrees (0 to 360).
             derived().x_values_style_.value_label_rotation_ = rotate;
             return derived();
           }
 
- int x_values_rotation()
+ template <class Derived>
+ int axis_plot_frame<Derived>::x_values_rotation()
           {
             return derived().x_values_style_.value_label_rotation_;
           }
 
- Derived& x_values_precision(int p)
+ template <class Derived>
+ Derived& axis_plot_frame<Derived>::x_values_precision(int p)
           { // set iostream precision
             derived().x_values_style_.value_precision_ = p;
             return derived();
           }
 
- int x_values_precision()
+ template <class Derived>
+ int axis_plot_frame<Derived>::x_values_precision()
           {
             return derived().x_values_style_.value_precision_;
           }
 
- Derived& x_values_ioflags(std::ios_base::fmtflags f)
+ template <class Derived>
+ Derived& axis_plot_frame<Derived>::x_values_ioflags(std::ios_base::fmtflags f)
           { // set iostream format flags
             derived().x_values_style_.value_ioflags_ = f;
             return derived();
           }
 
- std::ios_base::fmtflags x_values_ioflags()
+ template <class Derived>
+ std::ios_base::fmtflags axis_plot_frame<Derived>::x_values_ioflags()
           {
             return derived().x_values_style_.value_ioflags_;
           }
 
- Derived& x_plusminus_on(bool b)
+ template <class Derived>
+ Derived& axis_plot_frame<Derived>::x_plusminus_on(bool b)
           { // set if uncertainty to be append to X values labels.
             derived().x_values_style_.plusminus_on_ = b;
             return derived();
           }
 
- bool x_plusminus_on()
+ template <class Derived>
+ bool axis_plot_frame<Derived>::x_plusminus_on()
           {
             return derived().x_values_style_.plusminus_on_;
           }
- Derived& x_df_on(bool b)
+
+ template <class Derived>
+ Derived& axis_plot_frame<Derived>::x_df_on(bool b)
           { // set if uncertainty to be append to X values labels.
             derived().x_values_style_.df_on_ = b;
             return derived();
           }
 
- bool x_df_on()
+ template <class Derived>
+ bool axis_plot_frame<Derived>::x_df_on()
           {
             return derived().x_values_style_.df_on_;
           }
-
- double x_major_interval()
+
+ template <class Derived>
+ double axis_plot_frame<Derived>::x_major_interval()
           {
             return derived().x_ticks_.major_interval_;
           }
 
- Derived& x_major_tick_length(double length)
+ template <class Derived>
+ Derived& axis_plot_frame<Derived>::x_major_tick_length(double length)
           {
             derived().x_ticks_.major_tick_length_ = length;
             return derived();
           }
 
- double x_major_tick_length()
+ template <class Derived>
+ double axis_plot_frame<Derived>::x_major_tick_length()
           {
             return derived().x_ticks_.major_tick_length_;
           }
 
- Derived& x_major_tick_width(double width)
+ template <class Derived>
+ Derived& axis_plot_frame<Derived>::x_major_tick_width(double width)
           {
             derived().x_ticks_.major_tick_width_ = width; // Redundant?
             derived().image.g(PLOT_X_MAJOR_TICKS).style().stroke_width(width);
             return derived();
           }
 
- double x_major_tick_width()
+ template <class Derived>
+ double axis_plot_frame<Derived>::x_major_tick_width()
           {
             return derived().image.g(PLOT_X_MAJOR_TICKS).style().stroke_width();
           }
 
- Derived& x_minor_tick_length(double length)
+ template <class Derived>
+ Derived& axis_plot_frame<Derived>::x_minor_tick_length(double length)
           {
             derived().x_ticks_.minor_tick_length_ = length;
             return derived();
           }
 
- double x_minor_tick_length()
+ template <class Derived>
+ double axis_plot_frame<Derived>::x_minor_tick_length()
           {
             return derived().x_ticks_.minor_tick_length_;
           }
 
- Derived& x_minor_tick_width(double width)
+ template <class Derived>
+ Derived& axis_plot_frame<Derived>::x_minor_tick_width(double width)
           {
             derived().x_ticks_.minor_tick_width_ = width;
             derived().image.g(PLOT_X_MINOR_TICKS).style().stroke_width(width);
             return derived();
           }
 
- double x_minor_tick_width()
+
+ template <class Derived>
+ double axis_plot_frame<Derived>::x_minor_tick_width()
           {
             // return derived().x_minor_tick_width_; // should be the same but store in stroke_width is definitive.
             return derived().image.g(PLOT_X_MINOR_TICKS).style().stroke_width();
           }
 
- Derived& x_major_tick(double d)
+ template <class Derived>
+ Derived& axis_plot_frame<Derived>::x_major_tick(double d)
           { // Interval (Cartesian units) between major ticks.
             derived().x_ticks_.major_interval_ = d;
           }
 
- double x_major_tick()
+ template <class Derived>
+ double axis_plot_frame<Derived>::x_major_tick()
           { // Interval (Cartesian units) between major ticks.
             return derived().x_ticks_.major_interval_;
           }
 
- Derived& x_minor_interval(double interval)
+ template <class Derived>
+ Derived& axis_plot_frame<Derived>::x_minor_interval(double interval)
           { // aka x_minor_tick
             derived().x_ticks_.minor_interval_ = interval;
             return derived();
           }
 
- Derived& x_num_minor_ticks(unsigned int num)
+ template <class Derived>
+ Derived& axis_plot_frame<Derived>::x_num_minor_ticks(unsigned int num)
           {
             derived().x_ticks_.num_minor_ticks_ = num;
             return derived();
           }
 
- unsigned int x_num_minor_ticks()
+ template <class Derived>
+ unsigned int axis_plot_frame<Derived>::x_num_minor_ticks()
           { // NB NOT float or double!
             return derived().x_ticks_.num_minor_ticks_;
           }
 
- Derived& x_range(double min_x, double max_x)
+ template <class Derived>
+ Derived& axis_plot_frame<Derived>::x_range(double min_x, double max_x)
           {
             if (!boost::math::isfinite(min_x))
             {
@@ -2773,13 +3159,13 @@
             derived().x_axis_.max_ = max_x;
             //derived().x_ticks_.max_ = min_x;
             //derived().y_ticks_.max_ = max_x;
- // done in calculate_plot_window.
- // TODO May be best to combine these?
- derived().x_autoscale_ = false; // because range has just been set.
+ // done in calculate_plot_window, so need to duplicate here.
+ derived().x_autoscale_ = false; // Because explicit range has just been set.
             return derived();
           }
 
- std::pair<double, double> x_range()
+ template <class Derived>
+ std::pair<double, double> axis_plot_frame<Derived>::x_range()
           { // Need to use boost::svg::detail::operator<< to display this.
             std::pair<double, double> r;
             r.first = derived().x_axis_.min_;
@@ -2787,47 +3173,55 @@
             return r;
           }
 
- Derived& x_min(double min_x)
+ template <class Derived>
+ Derived& axis_plot_frame<Derived>::x_min(double min_x)
           {
             // Not useful to check here that x_max_ > x_min_ because may not have set x_min_ yet.
             derived().x_axis_.min_ = min_x;
             return derived();
           }
 
- double x_min()
+ template <class Derived>
+ double axis_plot_frame<Derived>::x_min()
           {
             return derived().x_axis_.min_;
           }
 
- Derived& x_max(double x)
+ template <class Derived>
+ Derived& axis_plot_frame<Derived>::x_max(double x)
           {
             // Not useful to check here that x_max_ > x_min_ because may not have set x_min_ yet.
             derived().x_axis_.max_ = x;
             return derived();
           }
 
- double x_max()
+ template <class Derived>
+ double axis_plot_frame<Derived>::x_max()
           {
             return derived().x_axis_.max_;
           }
 
- bool autoscale_check_limits()
+ template <class Derived>
+ bool axis_plot_frame<Derived>::autoscale_check_limits()
           {
             return derived().autoscale_check_limits_;
           }
 
- Derived& autoscale_check_limits(bool b)
+ template <class Derived>
+ Derived& axis_plot_frame<Derived>::autoscale_check_limits(bool b)
           { // Default is true, but can switch off checks for speed.
             derived().autoscale_check_limits_ = b;
             return derived();
           }
 
- bool x_autoscale()
+ template <class Derived>
+ bool axis_plot_frame<Derived>::x_autoscale()
           { // Get autoscale setting.
            return derived().x_autoscale_;
           }
 
- Derived& x_autoscale(bool b)
+ template <class Derived>
+ Derived& axis_plot_frame<Derived>::x_autoscale(bool b)
           { // set whether to use autoscaled values.
              if (b && derived().x_auto_tick_interval_ < 0)
              { // No autoscale values have been calculated, so not safe to make x_autoscale true.
@@ -2837,14 +3231,16 @@
             return derived();
           }
 
- bool autoscale()
+ template <class Derived>
+ bool axis_plot_frame<Derived>::autoscale()
           { // AKA x_autoscale.
            return derived().x_autoscale_;
           }
 
- Derived& autoscale(bool b)
+ template <class Derived>
+ Derived& axis_plot_frame<Derived>::autoscale(bool b)
           { // AKA x_autoscale - set whether to use X autoscaled values.
-
+ // Used by boxplot too.
              if (derived().x_auto_tick_interval_ < 0)
              { // No autoscale values have been calculated, so not safe to make x_autoscale true.
                 throw std::runtime_error("X-axis autoscale has not been calculated yet!" );
@@ -2853,7 +3249,8 @@
             return derived();
           }
 
- Derived& x_autoscale(std::pair<double, double> p)
+ template <class Derived>
+ Derived& axis_plot_frame<Derived>::x_autoscale(std::pair<double, double> p)
           { // Use X min & max pair values to autoscale.
               scale_axis(p.first, p.second, // double min and max from pair.
               &derived().x_auto_min_value_, &derived().x_auto_max_value_, &derived().x_auto_tick_interval_, &derived().x_auto_ticks_,
@@ -2863,59 +3260,81 @@
             return derived();
           } // autoscale(pair<double, double> p)
 
- template <class T> // T an STL container: array, vector ...
- Derived& x_autoscale(const T& begin, const T& end) // Data series using iterators
- { // to calculate autoscaled values.
- scale_axis(begin, end,
- &derived().x_auto_min_value_, &derived().x_auto_max_value_, &derived().x_auto_tick_interval_, &derived().x_auto_ticks_,
- derived().autoscale_check_limits_,
- derived().x_include_zero_, derived().x_tight_, derived().x_min_ticks_, derived().x_steps_);
 
- derived().x_autoscale_ = true; // Default to use calculated values.
- return derived();
- } // x_autoscale(const T& begin, const T& end)
+ // unable to match function definition to an existing declaration definition
+ // 'Derived &boost::svg::detail::axis_plot_frame<Derived>::x_autoscale(const T &,const T &)'
+ // existing declarations
+ // 'Derived &boost::svg::detail::axis_plot_frame<Derived>::x_autoscale(const T &)'
+ // 'Derived &boost::svg::detail::axis_plot_frame<Derived>::x_autoscale(const T &,const T &)'
+ // 'Derived &boost::svg::detail::axis_plot_frame<Derived>::x_autoscale(std::pair<_Ty1,_Ty2>)'
+ // with
+ // [
+ // _Ty1=double,
+ // _Ty2=double
+ // ]
+ // 'Derived &boost::svg::detail::axis_plot_frame<Derived>::x_autoscale(bool)'
+ //'bool boost::svg::detail::axis_plot_frame<Derived>::x_autoscale(void)'
+
 
- template <class T> // T an STL container: array, vector ...
- Derived& x_autoscale(const T& container) // Whole data series.
- { // to use to calculate autoscaled values.
- //scale_axis(container.begin(), container.end(), // All the container.
- scale_axis(container, // All the container.
- &derived().x_auto_min_value_, &derived().x_auto_max_value_, &derived().x_auto_tick_interval_, &derived().x_auto_ticks_,
- derived().autoscale_check_limits_,
- derived().x_include_zero_, derived().x_tight_, derived().x_min_ticks_, derived().x_steps_);
 
- derived().x_autoscale_ = true; // Default to use calculated values.
- return derived();
- } // x_autoscale(const T& container)
 
- // Set & get autoscale parameters,
- // Note: all these *MUST* preceed x_autoscale(data) call.
 
- Derived& x_with_zero(bool b)
+ //
+ //template <class Derived, class T> // T an STL container: array, vector ...
+ //Derived& axis_plot_frame<Derived>::x_autoscale(const T& begin, const T& end)
+ //{ // Data series using iterators to calculate autoscaled values.
+ // scale_axis(begin, end,
+ // &derived().x_auto_min_value_, &derived().x_auto_max_value_, &derived().x_auto_tick_interval_, &derived().x_auto_ticks_,
+ // derived().autoscale_check_limits_,
+ // derived().x_include_zero_, derived().x_tight_, derived().x_min_ticks_, derived().x_steps_);
+
+ // derived().x_autoscale_ = true; // Default to use calculated values.
+ // return derived();
+ //} // x_autoscale(const T& begin, const T& end)
+
+ //template <class Derived, class T> // T an STL container: array, vector ...
+ //Derived& axis_plot_frame<Derived>::x_autoscale(const T& container) // Whole data series.
+ //{ // to use to calculate autoscaled values.
+ // //scale_axis(container.begin(), container.end(), // All the container.
+ // scale_axis(container, // All the container.
+ // &derived().x_auto_min_value_, &derived().x_auto_max_value_, &derived().x_auto_tick_interval_, &derived().x_auto_ticks_,
+ // derived().autoscale_check_limits_,
+ // derived().x_include_zero_, derived().x_tight_, derived().x_min_ticks_, derived().x_steps_);
+
+ // derived().x_autoscale_ = true; // Default to use calculated values.
+ // return derived();
+ //} // x_autoscale(const T& container)
+
+ template <class Derived>
+ Derived& axis_plot_frame<Derived>::x_with_zero(bool b)
           { // Set autoscale to include zero (default = false).
             // Must preceed x_autoscale(data) call.
             derived().x_include_zero_ = b;
             return derived();
           }
 
- bool x_with_zero()
+ template <class Derived>
+ bool axis_plot_frame<Derived>::x_with_zero()
           { //
            return derived().x_include_zero_;
           }
 
- Derived& x_min_ticks(int min_ticks)
+ template <class Derived>
+ Derived& axis_plot_frame<Derived>::x_min_ticks(int min_ticks)
           { // Set autoscale to include at least min_ticks (default = 6).
             // Must preceed x_autoscale(data) call.
             derived().x_min_ticks_ = min_ticks;
             return derived();
           }
 
- int x_min_ticks()
+ template <class Derived>
+ int axis_plot_frame<Derived>::x_min_ticks()
           { //
            return derived().x_min_ticks_;
           }
 
- Derived& x_steps(int steps)
+ template <class Derived>
+ Derived& axis_plot_frame<Derived>::x_steps(int steps)
           { // Set autoscale to set ticks in steps 2,4,6,8,10, or 1,5,10 or 2,5,10.
             // default = 0 (none)
             // Must preceed x_autoscale(data) call.
@@ -2923,12 +3342,14 @@
             return derived();
           }
 
- int x_steps()
+ template <class Derived>
+ int axis_plot_frame<Derived>::x_steps()
           { //
            return derived().x_steps_;
           }
 
- Derived& x_tight(double tight)
+ template <class Derived>
+ Derived& axis_plot_frame<Derived>::x_tight(double tight)
           { // Set autoscale to include permit data points slightly outside both end ticks.
             // default 0.
             // Must preceed x_autoscale(data) call.
@@ -2936,55 +3357,36 @@
             return derived();
           }
 
- double x_tight()
+ template <class Derived>
+ double axis_plot_frame<Derived>::x_tight()
           { //
            return derived().x_tight_;
           }
 
- // Get results of autoscaling.
- double x_auto_min_value()
+ template <class Derived>
+ double axis_plot_frame<Derived>::x_auto_min_value()
           {
            return derived().x_auto_min_value_;
           }
 
- double x_auto_max_value()
+ template <class Derived>
+ double axis_plot_frame<Derived>::x_auto_max_value()
           {
            return derived().x_auto_max_value_;
           }
 
- double x_auto_tick_interval()
+ template <class Derived>
+ double axis_plot_frame<Derived>::x_auto_tick_interval()
           {
            return derived().x_auto_tick_interval_;
           }
+
 
- int x_auto_ticks()
- {
- return derived().x_auto_ticks_;
- }
-
- //// Stylesheet.
- // Removed for now to avoid compile warning in spirit.
-
- //Derived& load_stylesheet(const std::string& file)
- //{
- // derived().image.load_stylesheet(file);
- // return derived();
- //}
-
- //// Image info (& identical const version).
-
- //svg& get_svg()
- //{
- // derived()._update_image();
- // return derived().image;
- //}
-
- //const svg& get_svg() const
- //{
- // derived()._update_image();
- // return derived().image;
- //}
- }; // template <class Derived> class axis_plot_frame
+ template <class Derived>
+ int axis_plot_frame<Derived>::x_auto_ticks()
+ {
+ return derived().x_auto_ticks_;
+ }
 
       } // detail
     } // svg

Modified: sandbox/SOC/2007/visualization/boost/svg_plot/quantile.hpp
==============================================================================
--- sandbox/SOC/2007/visualization/boost/svg_plot/quantile.hpp (original)
+++ sandbox/SOC/2007/visualization/boost/svg_plot/quantile.hpp 2008-06-18 07:18:41 EDT (Wed, 18 Jun 2008)
@@ -11,6 +11,8 @@
 #ifndef BOOST_SVG_QUANTILE_HPP
 #define BOOST_SVG_QUANTILE_HPP
 
+#include <vector>
+using std::vector;
 
 // Estimate p th quantile of data using one of 5 definitions.
 // Default is the recommendation of Hyndman and Fan = definition #8.

Modified: sandbox/SOC/2007/visualization/boost/svg_plot/svg_1d_plot.hpp
==============================================================================
--- sandbox/SOC/2007/visualization/boost/svg_plot/svg_1d_plot.hpp (original)
+++ sandbox/SOC/2007/visualization/boost/svg_plot/svg_1d_plot.hpp 2008-06-18 07:18:41 EDT (Wed, 18 Jun 2008)
@@ -50,12 +50,12 @@
   class svg_1d_plot; // 1D Plot.
   class svg_1d_plot_series; // 1D Plot data series.
 
-// -----------------------------------------------------------------
+// ------------------------------------------------------------------
 // This allows us to store plot state locally in svg_plot.
 // Not stored in "svg" because transforming the points after they are
 // written to the document would be difficult. We store the Cartesian
 // coordinates locally and transform them before we write them.
-// -----------------------------------------------------------------
+// ------------------------------------------------------------------
 class svg_1d_plot_series
 {
 public:
@@ -67,119 +67,138 @@
   plot_point_style limit_point_style_; // Default is cone pointing down.
   plot_line_style line_style_; // No line style for 1-D, only for 2-D.
 
- // -------------------------------------------------------------
- // Scan each data point between the iterators that are passed,
- // sorting them into the correct std::vector, normal or not.
- // -------------------------------------------------------------
+ // Constructor svg_1d_plot_series.
   template <class T> // T an STL container: array, vector<double>, set, map ...
- svg_1d_plot_series(T begin, T end, const std::string& title = "")
- : // Constructor.
- title_(title),
- point_style_(black, blank, 5, vertical_line), // Default point style.
- limit_point_style_(grey, blank, 10, cone), // Default limit (inf or NaN) point style.
- line_style_(black, blank, 2, true, false) // Default line style, black, no fill, width, line_on, bezier_on false
- // Meaning of line style for 1-D as yet undefined?
- {
- for(T i = begin; i != end; ++i)
- { // No defaults for begin and end?
- double temp = *i;
- if(detail::is_limit(temp))
- {
- series_limits.push_back(temp); // 'limit' values: too big, too small or NaN.
- }
- else
- {
- series.push_back(temp); // Normal 'OK to plot' data values.
- }
- }
- } // svg_plot_series
+ svg_1d_plot_series(T begin, T end, const std::string& title = "");
+ // Scan each data point between the iterators that are passed,
+ // sorting them into the correct std::vectors, normal or not.
 
- // Set functions for the plot series.
- svg_1d_plot_series& fill_color(const svg_color& col_)
- {
- point_style_.fill_color_ = col_;
- return *this;
- }
+ // Declarations of Set functions for the plot series.
 
- svg_1d_plot_series& stroke_color(const svg_color& col_)
- {
- point_style_.stroke_color_ = col_;
- return *this;
- }
+ svg_1d_plot_series& fill_color(const svg_color& col_);
+ svg_1d_plot_series& stroke_color(const svg_color& col_);
+ svg_1d_plot_series& shape(point_shape shape_);
+ point_shape shape();
+ svg_1d_plot_series& symbols(const std::string s);
+ svg_1d_plot_series& size(int size_);
+ int size();
+ const std::string symbols();
+ svg_1d_plot_series& line_color(const svg_color& col_);
+ svg_1d_plot_series& line_width(double wid_);
 
- svg_1d_plot_series& shape(point_shape shape_)
- {
- point_style_.shape_ = shape_;
- return *this;
- }
+ // Get functions for the plot series.
 
- point_shape shape()
- {
- return point_style_.shape_;
+ double line_width();
+ svg_1d_plot_series& line_on(bool on_);
+ svg_1d_plot_series& bezier_on(bool on_);
+ bool bezier_on();
+}; // class svg_1d_plot_series
+
+// class svg_1d_plot_series Constructor
+template <class T> // T an STL container: array, vector<double>, set, map ...
+svg_1d_plot_series::svg_1d_plot_series(T begin, T end, const std::string& title)
+: // Constructor.
+title_(title),
+point_style_(black, blank, 5, vertical_line), // Default point style.
+limit_point_style_(grey, blank, 10, cone), // Default limit (inf or NaN) point style.
+line_style_(black, blank, 2, true, false) // Default line style, black, no fill, width, line_on, bezier_on false
+// Meaning of line style for 1-D as yet undefined?
+{
+ for(T i = begin; i != end; ++i)
+ { // No defaults for begin and end?
+ double temp = *i;
+ if(detail::is_limit(temp))
+ {
+ series_limits.push_back(temp); // 'limit' values: too big, too small or NaN.
+ }
+ else
+ {
+ series.push_back(temp); // Normal 'OK to plot' data values.
+ }
   }
+} // svg_plot_series constructor.
 
+// Definitions of svg_plot_series Member Functions.
 
- svg_1d_plot_series& symbols(const std::string s)
- {
- point_style_.symbols_ = s;
- return *this;
- }
+svg_1d_plot_series& svg_1d_plot_series::fill_color(const svg_color& col_)
+{
+ point_style_.fill_color_ = col_;
+ return *this;
+}
 
- svg_1d_plot_series& size(int size_)
- {
- //point_style_.size_ = size_;
- //point_style_.symbols_style_.font_size(i); // in case using a symbol.
- point_style_.size(size_);
+svg_1d_plot_series& svg_1d_plot_series::stroke_color(const svg_color& col_)
+{
+ point_style_.stroke_color_ = col_;
+ return *this;
+}
 
- return *this;
- }
+svg_1d_plot_series& svg_1d_plot_series::shape(point_shape shape_)
+{
+ point_style_.shape_ = shape_;
+ return *this;
+}
 
- int size()
- {
- return point_style_.size();
- }
+point_shape svg_1d_plot_series::shape()
+{
+ return point_style_.shape_;
+}
 
- const std::string symbols()
- {
- return point_style_.symbols_;
- }
+svg_1d_plot_series& svg_1d_plot_series::symbols(const std::string s)
+{
+ point_style_.symbols_ = s;
+ return *this;
+}
 
+svg_1d_plot_series& svg_1d_plot_series::size(int size_)
+{
+ //point_style_.size_ = size_;
+ //point_style_.symbols_style_.font_size(i); // in case using a symbol.
+ point_style_.size(size_);
+ return *this;
+}
 
- svg_1d_plot_series& line_color(const svg_color& col_)
- {
- line_style_.stroke_color_ = col_;
- return *this;
- }
+int svg_1d_plot_series::size()
+{
+ return point_style_.size();
+}
 
- svg_1d_plot_series& line_width(double wid_)
- {
- line_style_.width_ = wid_;
- return *this;
- }
+const std::string svg_1d_plot_series::symbols()
+{
+ return point_style_.symbols_;
+}
 
- // Get functions for the plot series.
- double line_width()
- {
- return line_style_.width_;
- }
+svg_1d_plot_series& svg_1d_plot_series::line_color(const svg_color& col_)
+{
+ line_style_.stroke_color_ = col_;
+ return *this;
+}
 
- svg_1d_plot_series& line_on(bool on_)
- {
- line_style_.line_on_ = on_;
- return *this;
- }
+svg_1d_plot_series& svg_1d_plot_series::line_width(double wid_)
+{
+ line_style_.width_ = wid_;
+ return *this;
+} double svg_1d_plot_series::line_width()
+{
+ return line_style_.width_;
+}
 
- svg_1d_plot_series& bezier_on(bool on_)
- {
- line_style_.bezier_on_ = on_;
- return *this;
- }
+svg_1d_plot_series& svg_1d_plot_series::line_on(bool on_)
+{
+ line_style_.line_on_ = on_;
+ return *this;
+}
 
- bool bezier_on()
- {
- return line_style_.bezier_on_;
- }
-}; // class svg_plot_series()
+svg_1d_plot_series& svg_1d_plot_series::bezier_on(bool on_)
+{
+ line_style_.bezier_on_ = on_;
+ return *this;
+}
+bool svg_1d_plot_series::bezier_on()
+{
+ return line_style_.bezier_on_;
+}
+
+// End Definitions of svg_plot_series Member Functions.
 
 class svg_1d_plot : public detail::axis_plot_frame<svg_1d_plot>
 { // See also svg_2d_plot.hpp for 2-D version.
@@ -639,7 +658,6 @@
     } // for
   } // void update_image()
 
-
   // ------------------------------------------------------------------------
   // write() has two versions: to an ostream and to a file.
   // The stream version first clears all unnecessary data from the graph,
@@ -647,8 +665,24 @@
   // document node, which calls all other nodes through the Visitor pattern.
   // The file version opens an ostream, and calls the stream version.
   // ------------------------------------------------------------------------
+ svg_1d_plot& write(const std::string& file);
+ svg_1d_plot& write(std::ostream& s_out);
 
- svg_1d_plot& write(const std::string& file)
+ // Versions of plot functions to add data series.
+ template <class T>
+ svg_1d_plot_series& plot(const T& container, const std::string& title = "");
+ template <class T>
+ svg_1d_plot_series& plot(const T& begin, const T& end, const std::string& title = "");
+ template <class T, class U>
+ svg_1d_plot_series& plot(const T& begin, const T& end, const std::string& title = "", U functor = boost_default_convert);
+ template <class T, class U>
+ svg_1d_plot_series& plot(const T& container, const std::string& title = "", U functor = boost_default_convert);
+}; // end svg_1d_plot::
+
+
+// svg_1d_plot Member functions definitions.
+
+ svg_1d_plot& svg_1d_plot::write(const std::string& file)
   {
     std::string filename(file); // Copy to avoid problems with const if need to append.
     if (filename.find(".svg") == std::string::npos)
@@ -666,7 +700,7 @@
     return *this;
   }
 
- svg_1d_plot& write(std::ostream& s_out)
+ svg_1d_plot& svg_1d_plot::write(std::ostream& s_out)
   {
     update_image();
     // Default stream precision 6 decimal digits is probably excessive.
@@ -679,9 +713,8 @@
     return (svg_1d_plot&)*this;
   }
 
- // Versions of plot functions to add data series.
   template <class T>
- svg_1d_plot_series& plot(const T& container, const std::string& title = "")
+ svg_1d_plot_series& svg_1d_plot::plot(const T& container, const std::string& title /*= "" */)
   { // Add a data series to the plot (by default, converting to doubles).
     // Note that this version assumes that *ALL* the data value in the container is used.
     series.push_back(
@@ -691,11 +724,11 @@
       title)
     );
    // For example: my_1d_plot.plot(my_data, "All my container");
- return series[series.size() - 1]; // Number of data series added so far.
+ return series[series.size() - 1]; // Reference to data series just added.
   }
 
   template <class T>
- svg_1d_plot_series& plot(const T& begin, const T& end, const std::string& title = "")
+ svg_1d_plot_series& svg_1d_plot::plot(const T& begin, const T& end, const std::string& title)
   { // Add a data series to the plot (by default, converting to doubles).
     // Note that this version permits a partial range,
     // begin to end, of the container to be used.
@@ -708,11 +741,11 @@
     // For example: my_1d_plot.plot(my_data.begin(), my_data.end(), "My container");
     // my_1d_plot.plot(&my_data[1], &my_data[4], "my_data 1 to 4"); // Add part of data series.
     // Care: last == end which is one past the last, so this only does 1, 2 & 3 - *not* 4!
- return series[series.size() - 1]; // Number of data series added so far.
- }
-
+ return series[series.size() - 1]; // Reference to data series just added.
+ }
+
   template <class T, class U>
- svg_1d_plot_series& plot(const T& begin, const T& end, const std::string& title = "", U functor = boost_default_convert)
+ svg_1d_plot_series& svg_1d_plot::plot(const T& begin, const T& end, const std::string& title /* = ""*/, U functor /* = boost_default_convert */)
   { // Add a data series to the plot. (Version with custom functor, rather than to double).
     series.push_back(
       svg_1d_plot_series(
@@ -720,11 +753,11 @@
       boost::make_transform_iterator(container.end(), functor),
       title)
     );
- return series[series.size() - 1]; // Number of data series added so far.
+ return series[series.size() - 1]; // Reference to data series just added.
   }
 
   template <class T, class U>
- svg_1d_plot_series& plot(const T& container, const std::string& title = "", U functor = boost_default_convert)
+ svg_1d_plot_series& svg_1d_plot::plot(const T& container, const std::string& title /* = "" */, U functor/*= boost_default_convert*/)
   { // Add a data series to the plot. (Version with functor, rather than to double).
     series.push_back(
       svg_1d_plot_series(
@@ -732,10 +765,10 @@
       boost::make_transform_iterator(container.end(), functor),
       title)
     );
- return series[series.size() - 1]; // Number of data series added so far.
+ return series[series.size() - 1]; // Reference to data series just added.
   }
 
-}; // end svg_1d_plot
+// End svg_1d_plot Member functions definitions.
 
 #if defined (BOOST_MSVC)
 # pragma warning(pop)

Modified: sandbox/SOC/2007/visualization/boost/svg_plot/svg_2d_plot.hpp
==============================================================================
--- sandbox/SOC/2007/visualization/boost/svg_plot/svg_2d_plot.hpp (original)
+++ sandbox/SOC/2007/visualization/boost/svg_plot/svg_2d_plot.hpp 2008-06-18 07:18:41 EDT (Wed, 18 Jun 2008)
@@ -46,16 +46,15 @@
     class svg_2d_plot; // Plot framework.
     class svg_2d_plot_series; // plot data series.
 
- // -----------------------------------------------------------------
+ // ------------------------------------------------------------------
     // This allows us to store plot state locally in svg_plot. We don't
     // store it in "svg" because transforming the points after they are
     // written to the document would be difficult. We store the Cartesian
     // coordinates locally and transform them before we write them.
- // -----------------------------------------------------------------
+ // ------------------------------------------------------------------
 
     class svg_2d_plot_series
     {
-
     friend svg_2d_plot_series;
     friend void draw_straight_lines(const svg_2d_plot_series&);
 
@@ -75,186 +74,221 @@
       bar_style bar_style_;
       histogram_style histogram_style_;
 
+ // Constructor.
       template <class T> // T an STL container: for example: multimap.
- svg_2d_plot_series(T begin, T end, // of data series.
- std::string title = "") // Title of data series.
- :
- title_(title),
- // plot_point_style(const svg_color& fill = blank, const svg_color& stroke = black,
- // int size = 10, point_shape shape = round, const std::string& symbols = "X")
- point_style_(black, blank, 10, round), // Default point style.
- limit_point_style_(grey, blank, 10, cone), // Default limit (inf or NaN) point style.
- line_style_(black, blank, 2, true, false), // Default line style, no fill, width 2, line_on, bezier off.
- bar_style_(black, blank, 3, no_bar), // Default black, no fill, stick width 3, no bar.
- // -2 block to Y-axis, -1 stick to Y-axis, no_bar, +1 stick to x_axis, -2 block to X-axis.
- histogram_style_(no_histogram)
-
- { // Constructor.
- for(T i = begin; i != end; ++i)
- { // Sort data points into normal and limited series.
- if(detail::pair_is_limit(*i))
- { // Either x and/or y is at limit.
- series_limits.insert(*i);
- }
- else
- { // Normal data values for both x and y.
- series.insert(*i);
- }
- }
- } // svg_2d_plot_series
-
+ svg_2d_plot_series(T begin, T end, // Container of data series.
+ std::string title = ""); // Title of data series.
 
       // Set functions for the plot series.
- svg_2d_plot_series& fill_color(const svg_color& col_)
- { // Point fill color.
- point_style_.fill_color_ = col_;
- return *this;
- }
-
- svg_2d_plot_series& stroke_color(const svg_color& col_)
- {
- point_style_.stroke_color_ = col_;
- return *this;
- }
-
- svg_2d_plot_series& shape(point_shape shape_)
- {
- point_style_.shape_ = shape_;
- return *this;
- }
-
- svg_2d_plot_series& size(int size_)
- {
- point_style_.size_ = size_;
- return *this;
- }
-
- svg_2d_plot_series& line_color(const svg_color& col_)
- {
- line_style_.stroke_color_ = col_;
- return *this;
- }
-
- svg_2d_plot_series& area_fill(const svg_color& col_)
- {
- line_style_.area_fill_ = col_;
- // Note that area_fill(false) will produce a *blank* color, and so NO FILL.
- // area_fill(blank) will produce the default non-blank color (black?).
- return *this;
- }
-
- svg_2d_plot_series& line_width(double wid_)
- {
- line_style_.width_ = wid_; // Sets legend line width too.
- return *this; // Make chainable.
- }
-
- svg_2d_plot_series& line_on(bool on_)
- {
- line_style_.line_on_ = on_;
- return *this; // Make chainable.
- }
-
- svg_2d_plot_series& bezier_on(bool on_)
- {
- line_style_.bezier_on_ = on_;
- return *this; // Make chainable.
- }
-
- svg_2d_plot_series& bar(bar_option opt_)
- {
- bar_style_.bar_option_ = opt_;
- return *this; // Make chainable.
- }
-
- svg_2d_plot_series& bar_width(double wid_)
- {
- bar_style_.width_ = wid_;
- return *this; // Make chainable.
- }
-
- svg_2d_plot_series& bar_color(const svg_color& col)
- {
- bar_style_.color_ = col;
- return *this; // Make chainable.
- }
-
- svg_2d_plot_series& bar_area_fill(const svg_color& col)
- {
- bar_style_.area_fill_ = col;
- return *this; // Make chainable.
- }
+ svg_2d_plot_series& fill_color(const svg_color& col_);
+ svg_2d_plot_series& stroke_color(const svg_color& col_);
+ svg_2d_plot_series& shape(point_shape shape_);
+ svg_2d_plot_series& size(int size_);
+ svg_2d_plot_series& line_color(const svg_color& col_);
+ svg_2d_plot_series& area_fill(const svg_color& col_);
+ svg_2d_plot_series& line_width(double wid_);
+ svg_2d_plot_series& line_on(bool on_);
+ svg_2d_plot_series& bezier_on(bool on_);
+ svg_2d_plot_series& bar_opt(bar_option);
+ svg_2d_plot_series& bar_width(double wid_);
+ svg_2d_plot_series& bar_color(const svg_color& col);
+ svg_2d_plot_series& bar_area_fill(const svg_color& col);
 
       // Get functions for the plot series.
- plot_line_style line_style()
- {
- return line_style_;
- }
-
- double line_width()
- {
- return line_style_.width_;
- }
-
- bool bezier_on()
- {
- return line_style_.bezier_on_;
- }
-
- bool line_on()
- {
- return line_style_.line_on_;
- }
-
- svg_color& line_color()
- {
- return line_style_.stroke_color_;
- }
-
- svg_color& area_fill()
- {
- return line_style_.area_fill_;
- }
-
- int size()
- {
- return point_style_.size_;
- }
+ plot_line_style line_style();
+ double line_width();
+ bool bezier_on();
+ bool line_on();
+ svg_color& line_color();
+ svg_color& area_fill();
+ int size();
+ point_shape shape();
+ bar_option bar_opt();
+ double bar_width();
+ svg_color& bar_color();
+ svg_color& bar_area_fill();
+ svg_2d_plot_series& histogram(histogram_option opt_);
+ }; // class svg_2d_plot_series
 
- point_shape shape()
- {
- return point_style_.shape_;
- }
+ // svg_2d_plot_series Member Functions Definitions.
 
- bar_option bar_option()
- {
- return bar_style_.bar_option_;
- }
+ // svg_2d_plot_series constructor.
 
- double bar_width()
- {
- return bar_style_.width_;
- }
-
- svg_color& bar_color()
- {
- return bar_style_.color_;
- }
-
- svg_color& bar_area_fill()
- {
- return bar_style_.area_fill_;
- }
-
- svg_2d_plot_series& histogram(histogram_option opt_)
- { // column = -1, // Bar or row line (stroke width) horizontal to Y-axis.
- // no_histogram = 0,
- // bar = +1 // Stick or column line (stroke width) vertical to X-axis.
- histogram_style_.histogram_option_ = opt_;
- return *this; // Make chainable.
+ template <class T> // T an STL container: for example: multimap.
+ svg_2d_plot_series::svg_2d_plot_series(T begin, T end, // of data series.
+ std::string title) // Title of data series.
+ :
+ title_(title),
+ // plot_point_style(const svg_color& fill = blank, const svg_color& stroke = black,
+ // int size = 10, point_shape shape = round, const std::string& symbols = "X")
+ point_style_(black, blank, 10, round), // Default point style.
+ limit_point_style_(grey, blank, 10, cone), // Default limit (inf or NaN) point style.
+ line_style_(black, blank, 2, true, false), // Default line style, no fill, width 2, line_on, bezier off.
+ bar_style_(black, blank, 3, no_bar), // Default black, no fill, stick width 3, no bar.
+ // -2 block to Y-axis, -1 stick to Y-axis, no_bar, +1 stick to x_axis, -2 block to X-axis.
+ histogram_style_(no_histogram)
+ { // Constructor.
+ for(T i = begin; i != end; ++i)
+ { // Sort data points into normal and limited series.
+ if(detail::pair_is_limit(*i))
+ { // Either x and/or y is at limit.
+ series_limits.insert(*i);
+ }
+ else
+ { // Normal data values for both x and y.
+ series.insert(*i);
       }
+ }
+ } // svg_2d_plot_series
 
- }; // class svg_2d_plot_series
+ svg_2d_plot_series& svg_2d_plot_series::fill_color(const svg_color& col_)
+ { // Point fill color.
+ point_style_.fill_color_ = col_;
+ return *this;
+ }
+
+ svg_2d_plot_series& svg_2d_plot_series::stroke_color(const svg_color& col_)
+ {
+ point_style_.stroke_color_ = col_;
+ return *this;
+ }
+
+ svg_2d_plot_series& svg_2d_plot_series::shape(point_shape shape_)
+ {
+ point_style_.shape_ = shape_;
+ return *this;
+ }
+
+ svg_2d_plot_series& svg_2d_plot_series::size(int size_)
+ {
+ point_style_.size_ = size_;
+ return *this;
+ }
+
+ svg_2d_plot_series& svg_2d_plot_series::line_color(const svg_color& col_)
+ {
+ line_style_.stroke_color_ = col_;
+ return *this;
+ }
+
+ svg_2d_plot_series& svg_2d_plot_series::area_fill(const svg_color& col_)
+ {
+ line_style_.area_fill_ = col_;
+ // Note that area_fill(false) will produce a *blank* color, and so NO FILL.
+ // area_fill(blank) will produce the default non-blank color (black?).
+ return *this;
+ }
+
+ svg_2d_plot_series& svg_2d_plot_series::line_width(double wid_)
+ {
+ line_style_.width_ = wid_; // Sets legend line width too.
+ return *this; // Make chainable.
+ }
+
+ svg_2d_plot_series& svg_2d_plot_series::line_on(bool on_)
+ {
+ line_style_.line_on_ = on_;
+ return *this; // Make chainable.
+ }
+
+ svg_2d_plot_series& svg_2d_plot_series::bezier_on(bool on_)
+ {
+ line_style_.bezier_on_ = on_;
+ return *this; // Make chainable.
+ }
+
+ svg_2d_plot_series& svg_2d_plot_series::bar_opt(bar_option opt_)
+ {
+ bar_style_.bar_option_ = opt_;
+ return *this; // Make chainable.
+ }
+
+ svg_2d_plot_series& svg_2d_plot_series::bar_width(double wid_)
+ {
+ bar_style_.width_ = wid_;
+ return *this; // Make chainable.
+ }
+
+ svg_2d_plot_series& svg_2d_plot_series::bar_color(const svg_color& col)
+ {
+ bar_style_.color_ = col;
+ return *this; // Make chainable.
+ }
+
+ svg_2d_plot_series& svg_2d_plot_series::bar_area_fill(const svg_color& col)
+ {
+ bar_style_.area_fill_ = col;
+ return *this; // Make chainable.
+ }
+
+ plot_line_style svg_2d_plot_series::line_style()
+ {
+ return line_style_;
+ }
+
+ double svg_2d_plot_series::line_width()
+ {
+ return line_style_.width_;
+ }
+
+ bool svg_2d_plot_series::bezier_on()
+ {
+ return svg_2d_plot_series::line_style_.bezier_on_;
+ }
+
+ bool svg_2d_plot_series::line_on()
+ {
+ return svg_2d_plot_series::line_style_.line_on_;
+ }
+
+ svg_color& svg_2d_plot_series::line_color()
+ {
+ return line_style_.stroke_color_;
+ }
+
+ svg_color& svg_2d_plot_series::area_fill()
+ {
+ return line_style_.area_fill_;
+ }
+
+ int svg_2d_plot_series::size()
+ {
+ return point_style_.size_;
+ }
+
+ point_shape svg_2d_plot_series::shape()
+ {
+ return point_style_.shape_;
+ }
+
+ bar_option svg_2d_plot_series::bar_opt()
+ {
+ return bar_style_.bar_option_;
+ }
+
+ double svg_2d_plot_series::bar_width()
+ {
+ return bar_style_.width_;
+ }
+
+ svg_color& svg_2d_plot_series::bar_color()
+ {
+ return bar_style_.color_;
+ }
+
+ svg_color& svg_2d_plot_series::bar_area_fill()
+ {
+ return bar_style_.area_fill_;
+ }
+
+ svg_2d_plot_series& svg_2d_plot_series::histogram(histogram_option opt_)
+ { // column = -1, // Bar or row line (stroke width) horizontal to Y-axis.
+ // no_histogram = 0,
+ // bar = +1 // Stick or column line (stroke width) vertical to X-axis.
+ histogram_style_.histogram_option_ = opt_;
+ return *this; // Make chainable.
+ }
+ // end svg_2d_plot_series Member Functions Definitions.
 
     class svg_2d_plot : public detail::axis_plot_frame<svg_2d_plot>
     { // See also svg_1d_plot.hpp for 1-D version.
@@ -304,7 +338,6 @@
       //bool x_plusminus_on_; // http://en.wikipedia.org/wiki/Plus-minus_sign
       //// Unicode &#0xB1; HTML &plusmn;
 
-
       //rotate_style y_value_label_rotation_; // Direction point Y value labels written.
       //int y_value_precision_;
       //std::ios_base::fmtflags y_value_ioflags_;
@@ -1677,254 +1710,363 @@
     } // void update_image()
 
 
- public: // Member functions
- // -----------------------------------------------------------------
+ public: // Declarations of member functions (definitions in separate file).
+
+ // All return *this to permit chaining.
+
       // write() has two flavors, a file and a ostream.
       // The file version opens an ostream, and calls the stream version.
       // The stream version first clears all unnecessary data from the graph,
       // builds the document tree, and then calls the write function for the root
       // document node, which calls all other nodes through the Visitor pattern.
- // -----------------------------------------------------------------
-
- svg_2d_plot& write(const std::string& file)
- { // Write the plot image to a named file.
- std::string filename(file); // Copy to avoid problem with const if try to append.
- if (filename.find(".svg") == std::string::npos)
- { // No file type suffix, so provide the default .svg.
- filename.append(".svg");
- }
-
- std::ofstream fout(filename.c_str());
- if(fout.fail())
- {
- throw std::runtime_error("Unable to open " + filename);
- }
- write(fout); // Using the ostream version.
- return *this;
- }
-
- svg_2d_plot& write(std::ostream& s_out)
- { // Write the image to an ostream.
- update_image();
- image.write(s_out); // Use the ostream version of write.
- return *this;
- }
+ svg_2d_plot& write(const std::string& file);
+ svg_2d_plot& write(std::ostream& s_out);
 
       // Member functions to set and get plot options.
- // All return *this to permit chaining.
 
       // These below only refer to 2D plot.
       // See axis_plot_label.hpp for all the many 1D functions X-Axis.
 
- axis_line_style& x_axis()
+ axis_line_style& x_axis();
+ axis_line_style& y_axis();
+ ticks_labels_style& x_ticks();
+ ticks_labels_style& y_ticks();
+ svg_2d_plot& y_label_on(bool cmd);
+ bool y_label_on();
+ svg_2d_plot& x_label_on(bool cmd);
+ bool x_label_on();
+ svg_2d_plot& y_major_labels_on(int cmd);
+ int y_major_labels_on();
+ svg_2d_plot& y_major_label_rotation(rotate_style rot);
+ int y_major_label_rotation();
+ svg_2d_plot& y_axis_width(double width);
+ double y_axis_width();
+ svg_2d_plot& y_value_precision(int digits);
+ int y_value_precision();
+ svg_2d_plot& y_value_ioflags( std::ios_base::fmtflags flags);
+ int y_value_ioflags();
+ svg_2d_plot& y_labels_strip_e0s(bool cmd);
+ bool y_labels_strip_e0s();
+ svg_2d_plot& y_axis_color(const svg_color& col);
+ svg_color y_axis_color();
+ svg_2d_plot& y_axis_label_color(const svg_color& col);
+ svg_color y_axis_label_color();
+ svg_2d_plot& y_label_units_on(bool b);
+ bool y_label_units_on();
+ svg_2d_plot& y_axis_value_color(const svg_color& col);
+ svg_color y_axis_value_color();
+ svg_2d_plot& y_label_width(double width);
+ double y_label_width();
+ svg_2d_plot& y_major_grid_color(const svg_color& col);
+ const svg_color y_major_grid_color();
+ svg_2d_plot& y_minor_grid_color(const svg_color& col);
+ const svg_color y_minor_grid_color();
+ svg_2d_plot& y_major_tick_color(const svg_color& col);
+ const svg_color y_major_tick_color();
+ svg_2d_plot& y_minor_tick_color(const svg_color& col);
+ const svg_color y_minor_tick_color();
+ const std::string y_axis_position();
+ svg_2d_plot& y_range(double min_y, double max_y);
+ std::pair<double, double> y_range();
+ double y_min();
+ double y_max();
+ bool y_autoscale();
+ svg_2d_plot& y_autoscale(bool b);
+ bool y_values_on();
+ svg_2d_plot& y_values_on(bool b);
+ bool xy_values_on();
+ svg_2d_plot& xy_values_on(bool b);
+ bool y_plusminus_on();
+ svg_2d_plot& y_plusminus_on(bool b);
+ bool y_df_on();
+ svg_2d_plot& y_df_on(bool b);
+ svg_2d_plot& y_autoscale(double first, double second);
+ svg_2d_plot& y_autoscale(std::pair<double, double> p);
+ template <class T> // T an STL container: array, vector ...
+ svg_2d_plot& y_autoscale(const T& begin, const T& end); // Data series using iterators to
+ template <class T> // T an STL container: array, vector ...
+ svg_2d_plot& y_autoscale(const T& container); // Whole data series.
+ template <class T> // T a 2D STL container: array, vector ...
+ svg_2d_plot& xy_autoscale(const T& container); // Whole data series,
+ bool xy_autoscale();
+ double y_major_tick_length();
+ svg_2d_plot& y_major_tick_length(double length);
+ double y_major_interval();
+ svg_2d_plot& y_major_interval(double inter);
+ svg_2d_plot& y_minor_tick_length(double length);
+ double y_minor_tick_length();
+ svg_2d_plot& y_num_minor_ticks(unsigned int num);
+ unsigned int y_num_minor_ticks();
+ svg_2d_plot& y_label_axis(const std::string& str);
+ std::string y_label_axis();
+ svg_2d_plot& y_major_tick_width(double width);
+ double y_major_tick_width();
+ svg_2d_plot& y_minor_tick_width(double width);
+ double y_minor_tick_width();
+ svg_2d_plot& x_ticks_on_window_or_axis(int is);
+ int x_ticks_on_window_or_axis();
+ svg_2d_plot& x_major_value_labels_side(int is);
+ int x_major_value_labels_side();
+ svg_2d_plot& y_ticks_on_window_or_axis(int is);
+ int y_ticks_on_window_or_axis();
+ svg_2d_plot& y_major_value_labels_side(int is);
+ int y_major_value_labels_side();
+ svg_2d_plot& y_ticks_left_on(bool cmd);
+ bool y_ticks_left_on();
+ svg_2d_plot& y_ticks_right_on(bool cmd);
+ bool y_ticks_right_on();
+ svg_2d_plot& y_major_grid_on(bool is);
+ bool y_major_grid_on();
+ svg_2d_plot& y_minor_grid_on(bool is);
+ bool y_minor_grid_on();
+ svg_2d_plot& y_minor_grid_width(double width);
+ double y_minor_grid_width();
+ svg_2d_plot& y_major_grid_width(double width);
+ double y_major_grid_width();
+ svg_2d_plot& y_label_font_size(unsigned int i);
+ unsigned int y_label_font_size();
+ svg_2d_plot& y_label_weight(std::string s);
+ const std::string& y_label_weight();
+ svg_2d_plot& y_label_font_family(const std::string& family);
+ const std::string& y_label_font_family();
+ svg_2d_plot& y_values_font_size(unsigned int i);
+ unsigned int y_values_font_size();
+ svg_2d_plot& y_values_font_family(const std::string& family);
+ const std::string& y_values_font_family();
+ svg_2d_plot& y_values_color(const svg_color& col);
+ svg_color y_values_color();
+ svg_2d_plot& y_values_rotation(rotate_style rotate);
+ int y_values_rotation();
+ svg_2d_plot& y_values_precision(int p);
+ int y_values_precision();
+ svg_2d_plot& y_values_ioflags(std::ios_base::fmtflags f);
+ std::ios_base::fmtflags y_values_ioflags();
+
+ // Versions of plot functions to add data series, all or part.
+ template <class T>
+ svg_2d_plot_series& plot(const T& container, const std::string& title = "");
+ template <class T, class U>
+ svg_2d_plot_series& plot(const T& container, const std::string& title = "", U functor = boost_default_2d_convert);
+ template <class T>
+ svg_2d_plot_series& plot(const T& begin, const T& end, const std::string& title = "");
+ template <class T, class U>
+ svg_2d_plot_series& plot(const T& begin, const T& end, const std::string& title = "", U functor = boost_default_2d_convert);
+
+ }; // class svg_2d_plot : public detail::axis_plot_frame<svg_2d_plot>
+
+ // Definition of member functions, (ready to be) externally defined in another (.ipp) file.
+
+ axis_line_style& svg_2d_plot::x_axis()
       {
         return x_axis_;
       }
 
- axis_line_style& y_axis()
+ axis_line_style& svg_2d_plot::y_axis()
       {
         return y_axis_;
       }
 
- ticks_labels_style& x_ticks()
+ ticks_labels_style& svg_2d_plot::x_ticks()
       {
         return x_ticks_;
       }
 
- ticks_labels_style& y_ticks()
+ ticks_labels_style& svg_2d_plot::y_ticks()
       {
         return y_ticks_;
       }
 
- svg_2d_plot& y_label_on(bool cmd)
+ svg_2d_plot& svg_2d_plot::y_label_on(bool cmd)
       { // If Y axis name or label.
         y_axis_.label_on_ = cmd;
         return *this; // Make chainable.
       }
 
- bool y_label_on()
+ bool svg_2d_plot::y_label_on()
       {
         return y_axis_.label_on_;
       }
 
- svg_2d_plot& x_label_on(bool cmd)
+ svg_2d_plot& svg_2d_plot::x_label_on(bool cmd)
       {
         x_axis_.label_on_ = cmd;
         return *this;
       }
 
- bool x_label_on()
+ bool svg_2d_plot::x_label_on()
       {
         return x_axis_.label_on_;
       }
 
- svg_2d_plot& y_major_labels_on(int cmd)
+ svg_2d_plot& svg_2d_plot::y_major_labels_on(int cmd)
       { //< 0 means to left or down (default), 0 (false) means none, > 0 means to right (or top).
         y_ticks_.major_value_labels_side_ = cmd;
         return *this;
       }
 
- int y_major_labels_on()
+ int svg_2d_plot::y_major_labels_on()
       {
         return y_ticks_.major_value_labels_side_;
       }
 
- svg_2d_plot& y_major_label_rotation(rotate_style rot)
+ svg_2d_plot& svg_2d_plot::y_major_label_rotation(rotate_style rot)
       {
         y_ticks_.label_rotation_ = rot;
         return *this;
       }
 
- int y_major_label_rotation()
+ int svg_2d_plot::y_major_label_rotation()
       {
         return y_ticks_.label_rotation_ ;
       }
 
- svg_2d_plot& y_axis_width(double width)
+
+ svg_2d_plot& svg_2d_plot::y_axis_width(double width)
       {
         image.g(detail::PLOT_Y_AXIS).style().stroke_width(width);
         return *this;
       }
 
- double y_axis_width()
+ double svg_2d_plot::y_axis_width()
       {
         return image.g(detail::PLOT_Y_AXIS).style().stroke_width();
       }
 
- svg_2d_plot& y_value_precision(int digits)
+ svg_2d_plot& svg_2d_plot::y_value_precision(int digits)
       { // Precision of Y tick label values in decimal digits (default 3).
         y_ticks_.value_precision_ = digits;
         return *this;
       }
 
- int y_value_precision()
+ int svg_2d_plot::y_value_precision()
       { // Precision of Y tick label values in decimal digits (default 3).
         return y_ticks_.value_precision_;
       }
 
- svg_2d_plot& y_value_ioflags( std::ios_base::fmtflags flags)
+ svg_2d_plot& svg_2d_plot::y_value_ioflags( std::ios_base::fmtflags flags)
       { // IO flags of Y tick label values (default 0X201).
         y_ticks_.value_ioflags_ = flags;
         return *this;
       }
 
- int y_value_ioflags()
+ int svg_2d_plot::y_value_ioflags()
       { // ALL stream ioflags for control of format of Y value labels.
         return y_ticks_.value_ioflags_;
       }
 
- svg_2d_plot& y_labels_strip_e0s(bool cmd)
+ svg_2d_plot& svg_2d_plot::y_labels_strip_e0s(bool cmd)
       {
         y_ticks_.strip_e0s_ = cmd;
         return *this;
       }
 
- bool y_labels_strip_e0s()
+ bool svg_2d_plot::y_labels_strip_e0s()
       {
         return y_ticks_.strip_e0s_;
       }
 
- svg_2d_plot& y_axis_color(const svg_color& col)
+ svg_2d_plot& svg_2d_plot::y_axis_color(const svg_color& col)
       { // Set only stroke color.
         image.g(detail::PLOT_Y_AXIS).style().stroke_color(col);
         return *this;
       }
 
- svg_color y_axis_color()
+ svg_color svg_2d_plot::y_axis_color()
       { // return the stroke color.
         return image.g(detail::PLOT_Y_AXIS).style().stroke_color();
       }
 
- svg_2d_plot& y_axis_label_color(const svg_color& col)
+ svg_2d_plot& svg_2d_plot::y_axis_label_color(const svg_color& col)
       { // Set stroke color.
         image.g(detail::PLOT_VALUE_LABELS).style().stroke_color(col);
         return *this;
       }
 
- svg_color y_axis_label_color()
+ svg_color svg_2d_plot::y_axis_label_color()
       { // But only return the stroke color.
         //return y_label_info_.style().stroke_color();
         return image.g(detail::PLOT_VALUE_LABELS).style().stroke_color();
       }
 
- svg_2d_plot& y_label_units_on(bool b)
+ svg_2d_plot& svg_2d_plot::y_label_units_on(bool b)
       {
         y_axis_.label_units_on_ = b;
         return *this;
       }
 
- bool y_label_units_on()
+ bool svg_2d_plot::y_label_units_on()
       {
         return y_axis_.label_units_on_;
       }
 
- svg_2d_plot& y_axis_value_color(const svg_color& col)
+ svg_2d_plot& svg_2d_plot::y_axis_value_color(const svg_color& col)
       {
         image.g(detail::PLOT_VALUE_LABELS).style().stroke_color(col);
         return *this;
       }
 
- svg_color y_axis_value_color()
+ svg_color svg_2d_plot::y_axis_value_color()
       { // Only return the stroke color.
         return image.g(detail::PLOT_VALUE_LABELS).style().stroke_color();
       }
 
- svg_2d_plot& y_label_width(double width)
+
+ svg_2d_plot& svg_2d_plot::y_label_width(double width)
       {
         image.g(detail::PLOT_Y_LABEL).style().stroke_width(width);
         return *this;
       }
 
- double y_label_width()
+ double svg_2d_plot::y_label_width()
       {
         return image.g(detail::PLOT_Y_LABEL).style().stroke_width();
       }
 
- svg_2d_plot& y_major_grid_color(const svg_color& col)
+ svg_2d_plot& svg_2d_plot::y_major_grid_color(const svg_color& col)
       {
         image.g(detail::PLOT_Y_MAJOR_GRID).style().stroke_color(col);
         return *this;
       }
 
- const svg_color y_major_grid_color()
+ const svg_color svg_2d_plot::y_major_grid_color()
       {
         return image.g(detail::PLOT_Y_MAJOR_GRID).style().stroke_color();
       }
 
- svg_2d_plot& y_minor_grid_color(const svg_color& col)
+ svg_2d_plot& svg_2d_plot::y_minor_grid_color(const svg_color& col)
       {
         image.g(detail::PLOT_Y_MINOR_GRID).style().stroke_color(col);
         return *this;
       }
 
- const svg_color y_minor_grid_color()
+ const svg_color svg_2d_plot::y_minor_grid_color()
       {
         return image.g(detail::PLOT_Y_MINOR_GRID).style().stroke_color();
       }
 
- svg_2d_plot& y_major_tick_color(const svg_color& col)
+ svg_2d_plot& svg_2d_plot::y_major_tick_color(const svg_color& col)
       {
         image.g(detail::PLOT_Y_MAJOR_TICKS).style().stroke_color(col);
         return *this;
       }
 
- const svg_color y_major_tick_color()
+ const svg_color svg_2d_plot::y_major_tick_color()
       {
         return image.g(detail::PLOT_Y_MAJOR_TICKS).style().stroke_color();
       }
 
- svg_2d_plot& y_minor_tick_color(const svg_color& col)
+ svg_2d_plot& svg_2d_plot::y_minor_tick_color(const svg_color& col)
       {
         image.g(detail::PLOT_Y_MINOR_TICKS).style().stroke_color(col);
         return *this;
       }
 
- const svg_color y_minor_tick_color()
+ const svg_color svg_2d_plot::y_minor_tick_color()
       {
         return image.g(detail::PLOT_Y_MINOR_TICKS).style().stroke_color();
       }
 
- const std::string y_axis_position()
+ const std::string svg_2d_plot::y_axis_position()
       {
         switch(y_axis_position_)
         {
@@ -1937,9 +2079,9 @@
         default:
           return "?"; break;
         }
- }
+ } // const std::string svg_2d_plot::y_axis_position()
 
- svg_2d_plot& y_range(double min_y, double max_y)
+ svg_2d_plot& svg_2d_plot::y_range(double min_y, double max_y)
       { // Set the range (max and min) for Y values.
         if (!boost::math::isfinite(min_y))
         {
@@ -1964,7 +2106,7 @@
        return *this;
       }
 
- std::pair<double, double> y_range()
+ std::pair<double, double> svg_2d_plot::y_range()
       {
         std::pair<double, double> r;
         r.first = y_axis_.min_;
@@ -1972,72 +2114,83 @@
         return r;
       }
 
- double y_min()
+ double svg_2d_plot::y_min()
       { // Can't check finite ness and relation to y_max.
         return y_axis_.min_;
       }
 
- double y_max()
+ double svg_2d_plot::y_max()
       { // Can't check finite ness and relation to y_min.
         return y_axis_.max_;
       }
 
- bool y_autoscale()
+ bool svg_2d_plot::y_autoscale()
       {
         return y_autoscale_;
       }
 
- svg_2d_plot& y_autoscale(bool b)
+ svg_2d_plot& svg_2d_plot::y_autoscale(bool b)
       {
         y_autoscale_ = b;
         return *this;
       }
 
- bool y_values_on()
+ bool svg_2d_plot::y_values_on()
       {
         return y_values_on_;
       }
 
- svg_2d_plot& y_values_on(bool b)
+ svg_2d_plot& svg_2d_plot::y_values_on(bool b)
       {
         y_values_on_ = b;
         return *this;
       }
 
- bool xy_values_on()
+ bool svg_2d_plot::xy_values_on()
       {
         return xy_values_on_;
       }
 
- svg_2d_plot& xy_values_on(bool b)
+ svg_2d_plot& svg_2d_plot::xy_values_on(bool b)
       {
         xy_values_on_ = b;
         return *this;
       }
 
- bool y_plusminus_on()
+
+ bool svg_2d_plot::y_plusminus_on()
       {
         return y_values_style_.plusminus_on_;
       }
 
- svg_2d_plot& y_plusminus_on(bool b)
+ svg_2d_plot& svg_2d_plot::y_plusminus_on(bool b)
       {
         y_values_style_.plusminus_on_ = b;
         return *this;
       }
 
- bool y_df_on()
+ bool svg_2d_plot::y_df_on()
       {
- return y_values_style_.df_on_;
+ return svg_2d_plot::y_values_style_.df_on_;
       }
 
- svg_2d_plot& y_df_on(bool b)
+ svg_2d_plot& svg_2d_plot::y_df_on(bool b)
       {
         y_values_style_.df_on_ = b;
         return *this;
       }
+
+ svg_2d_plot& svg_2d_plot::y_autoscale(double first, double second)
+ { // Use Y min & max values to autoscale.
+ scale_axis(first, second, // double min and max from two doubles.
+ &y_auto_min_value_, &y_auto_max_value_, &y_auto_tick_interval_, &y_auto_ticks_,
+ autoscale_check_limits_,
+ y_include_zero_, y_tight_, y_min_ticks_, y_steps_);
+ y_autoscale_ = true; // Default to use calculated values.
+ return *this;
+ } // autoscale(pair<double, double> p)
 
- svg_2d_plot& y_autoscale(std::pair<double, double> p)
+ svg_2d_plot& svg_2d_plot::y_autoscale(std::pair<double, double> p)
       { // Use Y min & max pair values to autoscale.
         scale_axis(p.first, p.second, // double min and max from pair.
         &y_auto_min_value_, &y_auto_max_value_, &y_auto_tick_interval_, &y_auto_ticks_,
@@ -2047,8 +2200,8 @@
         return *this;
       } // autoscale(pair<double, double> p)
 
- template <class T> // T an STL container: array, vector ...
- svg_2d_plot& y_autoscale(const T& begin, const T& end) // Data series using iterators to
+ template <class T> // T an STL container: array, vector ...
+ svg_2d_plot& svg_2d_plot::y_autoscale(const T& begin, const T& end) // Data series using iterators to
       { // to use to calculate autoscaled values.
         scale_axis(begin, end,
         &y_auto_min_value_, &y_auto_max_value_, &y_auto_tick_interval_, &y_auto_ticks_,
@@ -2058,8 +2211,10 @@
         return *this;
       }
 
+
+
       template <class T> // T an STL container: array, vector ...
- svg_2d_plot& y_autoscale(const T& container) // Whole data series.
+ svg_2d_plot& svg_2d_plot::y_autoscale(const T& container) // Whole data series.
       { // to use to calculate autoscaled values.
         scale_axis(container.begin(), container.end(), // All the container.
         &y_auto_min_value_, &y_auto_max_value_, &y_auto_tick_interval_, &y_auto_ticks_,
@@ -2070,7 +2225,7 @@
       }
 
       template <class T> // T a 2D STL container: array, vector ...
- svg_2d_plot& xy_autoscale(const T& container) // Whole data series,
+ svg_2d_plot& svg_2d_plot::xy_autoscale(const T& container) // Whole data series,
       { // to use to calculate autoscaled values for *both* X and Y axes.
         scale_axis(container, // All the container.
           &x_auto_min_value_, &x_auto_max_value_, &x_auto_tick_interval_, &x_auto_ticks_,
@@ -2083,269 +2238,265 @@
         return *this;
       } // xy_autoscale
 
- bool xy_autoscale()
+ bool svg_2d_plot::xy_autoscale()
       {
         return y_autoscale_ && x_autoscale_;
       }
 
- svg_2d_plot& y_major_interval(double inter)
+ svg_2d_plot& svg_2d_plot::y_major_interval(double inter)
       {
         y_ticks_.major_interval_ = inter;
         return *this;
       }
 
- double y_major_interval()
+ double svg_2d_plot::y_major_interval()
       {
         return y_ticks_.major_interval_;
       }
 
- svg_2d_plot& y_major_tick_length(double length)
+ svg_2d_plot& svg_2d_plot::y_major_tick_length(double length)
       {
         y_ticks_.major_tick_length_ = length;
         return *this;
       }
 
- double y_major_tick_length()
+ double svg_2d_plot::y_major_tick_length()
       {
         return y_ticks_.major_tick_length_;
       }
 
- svg_2d_plot& y_minor_tick_length(double length)
+ svg_2d_plot& svg_2d_plot::y_minor_tick_length(double length)
       {
         y_ticks_.minor_tick_length_ = length;
         return *this;
       }
 
- double y_minor_tick_length()
+ double svg_2d_plot::y_minor_tick_length()
       {
         return y_ticks_.minor_tick_length_;
       }
 
- svg_2d_plot& y_num_minor_ticks(unsigned int num)
+ svg_2d_plot& svg_2d_plot::y_num_minor_ticks(unsigned int num)
       {
         y_ticks_.num_minor_ticks_ = num;
         return *this;
       }
 
- unsigned int y_num_minor_ticks()
+ unsigned int svg_2d_plot::y_num_minor_ticks()
       {
         return y_ticks_.num_minor_ticks_;
       }
-
- svg_2d_plot& y_label_axis(const std::string& str)
+
+ svg_2d_plot& svg_2d_plot::y_label_axis(const std::string& str)
       { // Set label for Y-axis.
         y_label_info_.text(str);
         return *this;
       }
 
- std::string y_label_axis()
+ std::string svg_2d_plot::y_label_axis()
       { // text to label Y axis.
         return y_label_info_.text();
       }
 
- svg_2d_plot& y_major_tick_width(double width)
+ svg_2d_plot& svg_2d_plot::y_major_tick_width(double width)
       {
         y_ticks_.major_tick_width_ = width;
         image.g(detail::PLOT_Y_MAJOR_TICKS).style().stroke_width(width);
         return *this;
       }
 
- double y_major_tick_width()
+ double svg_2d_plot::y_major_tick_width()
       {
         return y_ticks_.major_tick_width_;
       }
 
- svg_2d_plot& y_minor_tick_width(double width)
+ svg_2d_plot& svg_2d_plot::y_minor_tick_width(double width)
       {
         y_ticks_.minor_tick_width_ = width;
         image.g(detail::PLOT_Y_MINOR_TICKS).style().stroke_width(width);
         return *this;
       }
 
- double y_minor_tick_width()
+ double svg_2d_plot::y_minor_tick_width()
       {
         return y_ticks_.minor_tick_width_;
       }
 
- svg_2d_plot& x_ticks_on_window_or_axis(int is)
+ svg_2d_plot& svg_2d_plot::x_ticks_on_window_or_axis(int is)
       {
         x_ticks_.ticks_on_window_or_axis_ = is;
         return *this;
       }
 
- int x_ticks_on_window_or_axis()
+ int svg_2d_plot::x_ticks_on_window_or_axis()
       {
         return x_ticks_.ticks_on_window_or_axis_;
       }
 
- svg_2d_plot& x_major_value_labels_side(int is)
+ svg_2d_plot& svg_2d_plot::x_major_value_labels_side(int is)
       { // Label values side for major ticks left -1, (right +1 or none 0).
         x_ticks_.major_value_labels_side_ = is;
         return *this;
       }
 
- int x_major_value_labels_side()
+ int svg_2d_plot::x_major_value_labels_side()
       { // Label values side for major ticks left -1, (right +1 or none 0).
         return x_ticks_.major_value_labels_side_;
       }
 
- svg_2d_plot& y_ticks_on_window_or_axis(int is)
+ svg_2d_plot& svg_2d_plot::y_ticks_on_window_or_axis(int is)
       {
         y_ticks_.ticks_on_window_or_axis_ = is;
         return *this;
       }
 
- int y_ticks_on_window_or_axis()
+ int svg_2d_plot::y_ticks_on_window_or_axis()
       {
         return y_ticks_.ticks_on_window_or_axis_;
       }
-
- svg_2d_plot& y_major_value_labels_side(int is)
+
+ svg_2d_plot& svg_2d_plot::y_major_value_labels_side(int is)
       { // Label values side for major ticks left -1, (right +1 or none 0).
         y_ticks_.major_value_labels_side_ = is;
         return *this;
       }
 
- int y_major_value_labels_side()
+ int svg_2d_plot::y_major_value_labels_side()
       { // Label values side for major ticks left -1, (right +1 or none 0).
         return y_ticks_.major_value_labels_side_;
       }
 
- svg_2d_plot& y_ticks_left_on(bool cmd)
+ svg_2d_plot& svg_2d_plot::y_ticks_left_on(bool cmd)
       {
         y_ticks_.left_ticks_on_ = cmd;
         return *this;
       }
 
- bool y_ticks_left_on()
+ bool svg_2d_plot::y_ticks_left_on()
       {
         return y_ticks_.left_ticks_on_;
       }
 
- svg_2d_plot& y_ticks_right_on(bool cmd)
+
+
+ svg_2d_plot& svg_2d_plot::y_ticks_right_on(bool cmd)
       {
         y_ticks_.right_ticks_on_ = cmd;
         return *this;
       }
 
- bool y_ticks_right_on()
+ bool svg_2d_plot::y_ticks_right_on()
       {
         return y_ticks_.right_ticks_on_;
       }
       // Only need y_ticks_left_on & y_ticks_right_on in 2D
 
 
- svg_2d_plot& y_major_grid_on(bool is)
+ svg_2d_plot& svg_2d_plot::y_major_grid_on(bool is)
       {
         y_ticks_.major_grid_on_ = is;
         return *this;
       }
 
- bool y_major_grid_on()
+ bool svg_2d_plot::y_major_grid_on()
       {
         return y_ticks_.major_grid_on_;
       }
 
- svg_2d_plot& y_minor_grid_on(bool is)
+
+ svg_2d_plot& svg_2d_plot::y_minor_grid_on(bool is)
       {
         y_ticks_.minor_grid_on_ = is;
         return *this;
       }
 
- bool y_minor_grid_on()
+ bool svg_2d_plot::y_minor_grid_on()
       {
         return y_ticks_.minor_grid_on_;
       }
 
- svg_2d_plot& y_minor_grid_width(double width)
+ svg_2d_plot& svg_2d_plot::y_minor_grid_width(double width)
       {
         y_ticks_.minor_grid_width_ = width;
         image.g(detail::PLOT_Y_MINOR_GRID).style().stroke_width(width);
         return *this;
       }
 
- double y_minor_grid_width()
+ double svg_2d_plot::y_minor_grid_width()
       {
         return y_ticks_.minor_grid_width_;
       }
 
- svg_2d_plot& y_major_grid_width(double width)
+
+
+ svg_2d_plot& svg_2d_plot::y_major_grid_width(double width)
       {
         y_ticks_.major_grid_width_ = width;
         image.g(detail::PLOT_Y_MAJOR_GRID).style().stroke_width(width);
         return *this;
       }
 
- double y_major_grid_width()
+ double svg_2d_plot::y_major_grid_width()
       {
         return y_ticks_.major_grid_width_;
       }
 
- svg_2d_plot& y_label_font_size(unsigned int i)
+ svg_2d_plot& svg_2d_plot::y_label_font_size(unsigned int i)
       { // May be best to tie label & unit font sizes together?
         x_axis_label_style_.font_size(i);
         // y_units_info_.font_size(i);
         return *this;
       }
 
- unsigned int y_label_font_size()
+ unsigned int svg_2d_plot::y_label_font_size()
       {
         return y_axis_label_style_.font_size();
       }
 
- // Note useful until browsers support.
- //svg_2d_plot& y_label_weight(std::string s)
- //{ // "bold" is only one that works so far.
- // x_axis_label_style_.font_weight(s);
- // return *this;
- //}
 
- //const std::string& y_label_weight()
- //{
- // return x_axis_label_style_.font_weight();
- //}
 
+ svg_2d_plot& svg_2d_plot::y_label_weight(std::string s)
+ { // "bold" is only one that works so far.
+ x_axis_label_style_.font_weight(s);
+ return *this;
+ }
+
+ const std::string& svg_2d_plot::y_label_weight()
+ {
+ return x_axis_label_style_.font_weight();
+ }
 
 
- svg_2d_plot& y_label_font_family(const std::string& family)
+ svg_2d_plot& svg_2d_plot::y_label_font_family(const std::string& family)
       {
         x_axis_label_style_.font_family(family);
         return *this;
       }
 
- const std::string& y_label_font_family();
- //const std::string& y_label_font_family()
- //{
- // return y_label_info_.font_family();
- //}
-
- // Example of declaration but definition below.
- // TODO Probably better done this way,
-
 
- svg_2d_plot& y_values_font_size(unsigned int i)
+ svg_2d_plot& svg_2d_plot::y_values_font_size(unsigned int i)
       {
         y_values_style_.values_text_style_.font_size(i);
         return *this;
       }
 
- unsigned int y_values_font_size()
+ unsigned int svg_2d_plot::y_values_font_size()
       {
         return y_values_style_.values_text_style_.font_size();
       }
 
- svg_2d_plot& y_values_font_family(const std::string& family)
+ svg_2d_plot& svg_2d_plot::y_values_font_family(const std::string& family)
       {
         y_values_style_.values_text_style_.font_family(family);
         return *this;
       }
 
- const std::string& y_values_font_family()
+ const std::string& svg_2d_plot::y_values_font_family()
       {
         return y_values_style_.values_text_style_.font_family();
       }
 
- svg_2d_plot& y_values_color(const svg_color& col)
+ svg_2d_plot& svg_2d_plot::y_values_color(const svg_color& col)
       { // Function could set both fill (middle) and stroke (outside),
         // but just setting fill if simplest,
         // but does not allow separate inside & outside colors.
@@ -2354,113 +2505,133 @@
         return *this;
       }
 
- svg_color y_values_color()
+ svg_color svg_2d_plot::y_values_color()
       { // Function could get either fill and stroke,
         // return svg_2d_plot().image.g(PLOT_Y_POINT_VALUES).style().stroke_color();
         return image.g(detail::PLOT_Y_POINT_VALUES).style().fill_color();
       }
 
- svg_2d_plot& y_values_rotation(rotate_style rotate)
+ svg_2d_plot& svg_2d_plot::y_values_rotation(rotate_style rotate)
       { // Degrees (0 to 360).
         y_values_style_.value_label_rotation_ = rotate;
         return *this;
       }
 
- int y_values_rotation()
+ int svg_2d_plot::y_values_rotation()
       {
         return y_values_style_.value_label_rotation_;
       }
 
- svg_2d_plot& y_values_precision(int p)
+
+ svg_2d_plot& svg_2d_plot::y_values_precision(int p)
       { // set iostream precision
         y_values_style_.value_precision_ = p;
         return *this;
       }
 
- int y_values_precision()
+ int svg_2d_plot::y_values_precision()
       {
         return y_values_style_.value_precision_;
       }
 
- svg_2d_plot& y_values_ioflags(std::ios_base::fmtflags f)
+ svg_2d_plot& svg_2d_plot::y_values_ioflags(std::ios_base::fmtflags f)
       { // set iostream format flags
         y_values_style_.value_ioflags_ = f;
         return *this;
       }
 
- std::ios_base::fmtflags y_values_ioflags()
+ std::ios_base::fmtflags svg_2d_plot::y_values_ioflags()
       {
         return y_values_style_.value_ioflags_;
       }
 
 
- // Versions of plot functions to add data series, all or part.
-
- template <class T>
- svg_2d_plot_series& plot(const T& container, const std::string& title = "")
- { // Version converting to double.
- // Note that this version assumes that *ALL* the data value in the container is used.
- series.push_back(
- svg_2d_plot_series(
- boost::make_transform_iterator(container.begin(), detail::boost_default_2d_convert()),
- boost::make_transform_iterator(container.end(), detail::boost_default_2d_convert()),
- title)
- );
- return series[series.size()-1]; // Number of data series added so far.
- }
-
- template <class T, class U>
- svg_2d_plot_series& plot(const T& container, const std::string& title = "", U functor = boost_default_2d_convert)
- { // Version with functor.
- // Note that this version assumes that *ALL* the data value in the container is used.
- series.push_back(
- svg_2d_plot_series(
- boost::make_transform_iterator(container.begin(), functor),
- boost::make_transform_iterator(container.end(), functor),
- title)
- );
- return series[series.size()-1]; // Number of data series added so far.
- }
+ svg_2d_plot& svg_2d_plot::write(const std::string& file)
+ { // Write the plot image to a named file.
+ std::string filename(file); // Copy to avoid problem with const if try to append.
+ if (filename.find(".svg") == std::string::npos)
+ { // No file type suffix, so provide the default .svg.
+ filename.append(".svg");
+ }
 
- template <class T>
- svg_2d_plot_series& plot(const T& begin, const T& end, const std::string& title = "")
- { // Add a data series to the plot (by default, converting to doubles).
- // Note that this version permits a *partial range*,
- // begin to end, of the container to be used.
- series.push_back(
- svg_2d_plot_series(
- boost::make_transform_iterator(begin, detail::boost_default_convert()),
- boost::make_transform_iterator(end, detail::boost_default_convert()),
- title)
- );
- // For example: my_2d_plot.plot(my_data.begin(), my_data.end(), "My container");
- // my_2d_plot.plot(&my_data[1], &my_data[4], "my_data 1 to 4"); // Add part of data series.
- // Care: last == end which is one past the last, so this only does 1, 2 & 3 - *not* 4!
- return series[series.size() - 1]; // Number of data series added so far.
- }
+ std::ofstream fout(filename.c_str());
+ if(fout.fail())
+ {
+ throw std::runtime_error("Unable to open " + filename);
+ }
+ write(fout); // Using the ostream version.
+ return *this;
+ }
+
+ template <class T>
+ svg_2d_plot_series& svg_2d_plot::plot(const T& container, const std::string& title)
+ { // Version converting to double.
+ // Note that this version assumes that *ALL* the data value in the container is used.
+ series.push_back(
+ svg_2d_plot_series(
+ boost::make_transform_iterator(container.begin(), detail::boost_default_2d_convert()),
+ boost::make_transform_iterator(container.end(), detail::boost_default_2d_convert()),
+ title)
+ );
+ return series[series.size()-1]; // Reference to data series just added.
+ }
+
+ template <class T, class U>
+ svg_2d_plot_series& svg_2d_plot::plot(const T& container, const std::string& title /* = "" */, U functor /* = boost_default_2d_convert*/)
+ { // Version with functor.
+ // Note that this version assumes that *ALL* the data value in the container is used.
+ series.push_back(
+ svg_2d_plot_series(
+ boost::make_transform_iterator(container.begin(), functor),
+ boost::make_transform_iterator(container.end(), functor),
+ title)
+ );
+ return series[series.size()-1];// Reference to data series just added.
+ }
+
+ template <class T>
+ svg_2d_plot_series& svg_2d_plot::plot(const T& begin, const T& end, const std::string& title)
+ { // Add a data series to the plot (by default, converting to doubles).
+ // Note that this version permits a *partial range*,
+ // begin to end, of the container to be used.
+ series.push_back(
+ svg_2d_plot_series(
+ boost::make_transform_iterator(begin, detail::boost_default_convert()),
+ boost::make_transform_iterator(end, detail::boost_default_convert()),
+ title)
+ );
+ // For example: my_2d_plot.plot(my_data.begin(), my_data.end(), "My container");
+ // my_2d_plot.plot(&my_data[1], &my_data[4], "my_data 1 to 4"); // Add part of data series.
+ // Care: last == end which is one past the last, so this only does 1, 2 & 3 - *not* 4!
+ return series[series.size() - 1]; // Reference to data series just added.
+ } // plot(const T& begin, const T& end, const std::string& title = "")
+
+ template <class T, class U>
+ svg_2d_plot_series& svg_2d_plot::plot(const T& begin, const T& end, const std::string& title, U functor)
+ { // Add a data series to the plot. (Version with custom functor, rather than to double).
+ // Note that this version permits a partial range,
+ // begin to end, of the container to be used.
+ series.push_back(
+ svg_2d_plot_series(
+ boost::make_transform_iterator(container.begin(), functor),
+ boost::make_transform_iterator(container.end(), functor),
+ title)
+ );
+ return series[series.size() - 1]; // Reference to data series just added.
+ }
 
- template <class T, class U>
- svg_2d_plot_series& plot(const T& begin, const T& end, const std::string& title = "", U functor = boost_default_2d_convert)
- { // Add a data series to the plot. (Version with custom functor, rather than to double).
- // Note that this version permits a partial range,
- // begin to end, of the container to be used.
- series.push_back(
- svg_2d_plot_series(
- boost::make_transform_iterator(container.begin(), functor),
- boost::make_transform_iterator(container.end(), functor),
- title)
- );
- return series[series.size() - 1]; // Number of data series added so far.
+ svg_2d_plot& svg_2d_plot::write(std::ostream& s_out)
+ { // Write the image to an ostream.
+ update_image();
+ image.write(s_out); // Use the ostream version of write.
+ return *this;
       }
 
- }; // class svg_2d_plot : public detail::axis_plot_frame<svg_2d_plot>
 
- // sample of declared function, externally defined in another .cpp file.
- // TODO May be useful to refactor all functions this way.
- const std::string& svg_2d_plot::y_label_font_family()
- {
- return y_axis_label_style_.font_family();
- }
+ const std::string& svg_2d_plot::y_label_font_family()
+ {
+ return y_axis_label_style_.font_family();
+ }
 
 #if defined (BOOST_MSVC)
 # pragma warning(pop)

Modified: sandbox/SOC/2007/visualization/boost/svg_plot/svg_boxplot.hpp
==============================================================================
--- sandbox/SOC/2007/visualization/boost/svg_plot/svg_boxplot.hpp (original)
+++ sandbox/SOC/2007/visualization/boost/svg_plot/svg_boxplot.hpp 2008-06-18 07:18:41 EDT (Wed, 18 Jun 2008)
@@ -18,7 +18,7 @@
 // Michael Frigge, David C. Hoaglin and Boris Iglewicz
 // The American Statistician, Vol. 43, No. 1 (Feb., 1989), pp. 50-54
 
-// The Bagplot: A Bivariate Boxplot
+// See also : The Bagplot: A Bivariate Boxplot
 // Peter J. Rousseeuw, Ida Ruts and John W. Tukey
 // The American Statistician, Vol. 53, No. 4 (Nov., 1999), pp. 382-387
 
@@ -39,6 +39,7 @@
 #include "detail/svg_boxplot_detail.hpp"
 #include "detail/functors.hpp"
 #include "detail/axis_plot_frame.hpp"
+#include "detail/auto_axes.hpp" //
 #include "quantile.hpp"
 
 #include <vector>
@@ -674,7 +675,7 @@
   bool y_include_zero_; // If autoscaled, include zero.
   int y_min_ticks_; // If autoscaled, set a minimum number of Y ticks.
   double y_tight_;
- int y_steps_; // If autoscaled, set any prescaling to decimal 1, 2, 5, 10 etc.
+ int y_steps_; // If autoscaled, set any prescaling to decimal 1, 2, 5, 10 etc.
 
     // Values calculated by scale_axis, and is used only if y_autoscale == true.
   double y_auto_min_value_;
@@ -741,8 +742,14 @@
   x_autoscale_(false),
   x_include_zero_(false), // If autoscaled, include zero.
   x_min_ticks_(6), // If autoscaled, set a minimum number of ticks, default 6.
- x_steps_(0), // If autoscaled, set any prescaling to decimal 1, 2, 5, 10 etc, default none.
+ x_steps_(0), // If autoscaled, set any prescaling to decimal 1, 2, 5, 10 etc, default none (0).
   x_tight_(1e-6), // margin that point can lie outside top and bottom tick.
+
+ y_include_zero_(false), // If autoscaled, include zero on Y-axis.
+ y_min_ticks_(6), // If autoscaled, set a minimum number of ticks, default 6.
+ y_steps_(0), // If autoscaled, set any prescaling to decimal 1, 2, 5, 10 etc, default none.
+ y_tight_(1e-6), // margin that point can lie outside top and bottom tick.
+
   y_autoscale_(false), // Not used for 1-D.
 
   text_margin_(2.), // for axis label text, as a multiplier of the font size.
@@ -760,8 +767,8 @@
   // Used to transform Cartesian to SVG.
   x_scale_(1.), x_shift_(0.),
   y_scale_(1.), y_shift_(0.),
- x_axis_position_(x_intersects_y),
- y_axis_position_(0),
+ x_axis_position_(bottom), // Default, but can be changed to top.
+ y_axis_position_(left), // Default, but can be changed to right.
 
   // Box'n'whiskers default values (used in svg_boxplot_series construction)
   // Can be changed for all plots using svg_boxplot member functions.
@@ -817,7 +824,7 @@
       image.g(boxplot::Y_MINOR_GRID).style().stroke_width(y_ticks_.minor_grid_width_).stroke_color(svg_color(200, 220, 255));
     }
 
- image.g(boxplot::X_LABEL).style().fill_color(black); // for text only specify fill_color
+ image.g(boxplot::X_LABEL).style().fill_color(black); // for text only specify fill_color (NOT stroke color).
     image.g(boxplot::Y_LABEL).style().fill_color(black);
     image.g(boxplot::VALUE_LABELS).style().fill_color(black);
     image.g(boxplot::PLOT_TITLE).style().fill_color(black);
@@ -915,9 +922,9 @@
       x_ticks_.ticks_on_window_or_axis_ = +1; // top = true;
     }
     // Y axis position is NOT determined by the range of X values.
- y_axis_position_ = y_intersects_x; // Assume Y-axis will intersect X-axis (X range includes zero).
- //x_axis_position_ = x_intersects_y; // Assume X-axis will intersect Y-axis (X range includes zero).
- x_axis_position_ = bottom; // Assume X-axis will intersect Y-axis (X range includes zero).
+ //x_axis_position_ = bottom; // Assume X-axis will intersect Y-axis (X range includes zero).
+ //y_axis_position_ = left; // Assume X-axis will intersect Y-axis (X range includes zero).
+ // Default in constructor, but could be changed to top and/or left.
 
     // Ensure both axis and ticks have the *same* range.
     // (To use the separation, made to give the potential for different ranges,
@@ -1055,9 +1062,10 @@
     } // if (use_x_axis_line_)
 
     if (y_axis_.axis_line_on_)
- { // Want a vertical Y-axis line, so check if range includes zero, so axes intersect,
+ { // Want a vertical Y-axis line,
+ // For boxplot do not check if range includes zero, so axes intersect,
       // and y_axis_ is svg coordinate of X-axis (usually x = 0).
- // If not fix axis to left (or right) of the plot window.
+ // Instead fix axis to left (or right) of the plot window.
       if ((y_axis_position_ == left) // All X values definitely > zero.
          //&& !(y_ticks_.ticks_on_window_or_axis_ < 0) // & not already at left.
          )
@@ -1070,12 +1078,13 @@
         )
       {
         y_axis_.axis_ = plot_right_; // Y-axis to right of plot window,
- }
- else
- {
- x_axis_position_ = x_intersects_y;
- // Calculate below after transform is calculated.
- }
+ }
+ //else
+ // for boxplot, Y-axis is always to right or left.
+ //{
+ // x_axis_position_ = x_intersects_y;
+ // // Calculate below after transform is calculated.
+ //}
     } // if (use_y_axis_line_)
 
     // plot window now calculated, so make some checks (might also check it fits into image?).
@@ -1107,15 +1116,16 @@
         x_axis_.axis_ = y; // svg Y coordinate of horizontal X-axis line.
       }
     }
- if (y_axis_.axis_line_on_)
- { // May need to calculate axes, if will intersect.
- if(y_axis_position_ == y_intersects_x)
- { // X Range *does* include zero, so y_axis_ not yet calculated.
- double x(0.);
- transform_x(x);
- y_axis_.axis_ = x; // SVG x coordinate of vertical Y-axis.
- }
- }
+ // For boxplot, Y axis is only ever left or right.
+ //if (y_axis_.axis_line_on_)
+ //{ // May need to calculate axes, if will intersect.
+ // if(y_axis_position_ == y_intersects_x)
+ // { // X Range *does* include zero, so y_axis_ not yet calculated.
+ // double x(0.);
+ // transform_x(x);
+ // y_axis_.axis_ = x; // SVG x coordinate of vertical Y-axis.
+ // }
+ //}
     if (plot_window_on_)
     { // Draw plot window rectangle with border and/or background.
       image.g(detail::PLOT_WINDOW_BACKGROUND).push_back(
@@ -1136,21 +1146,23 @@
   } // void draw_title()
 
   void draw_x_axis()
- { // Draw the horizontal X axis line.
- double y(0.);
- transform_y(y);
- //x_axis_. = y;
-
+ { // Draw the horizontal X-axis line.
     if (x_axis_.axis_line_on_)
- { // Want a Y-axis line.
-
+ { // Want a X-axis line.
       if (x_axis_position_ == top)
       { // horizontal line at top of plot window.
- image.g(boxplot::X_TICKS).line(plot_left_, plot_top_, plot_right_, plot_top_);
+ image.g(boxplot::X_AXIS).line(plot_left_, plot_top_, plot_right_, plot_top_);
       }
       else if (x_axis_position_ == bottom)
       {// horizontal line at bottom of plot window.
- image.g(boxplot::X_TICKS).line(plot_left_, plot_bottom_, plot_right_, plot_bottom_);
+ image.g(boxplot::X_AXIS).line(plot_left_, plot_bottom_, plot_right_, plot_bottom_);
+ }
+ else
+ { // horizontal line at y = 0
+ double y(0.);
+ transform_y(y);
+ //x_axis_. = y;
+ image.g(boxplot::X_AXIS).line(plot_left_, y, plot_right_, y);
       }
     }
     path_element& major_tick_path = image.g(boxplot::X_TICKS).path();
@@ -1165,6 +1177,18 @@
 
   void draw_y_axis()
   {
+ if (y_axis_.axis_line_on_)
+ { // Want a vertical Y-axis line, for boxplot only ever left or right.
+ if (y_axis_position_ == left)
+ { // Vertical line at left of plot window.
+ image.g(boxplot::Y_AXIS).line(plot_left_, plot_bottom_, plot_left_, plot_top_);
+ }
+ else if (y_axis_position_ == right)
+ {// Vertical line at right of plot window.
+ image.g(boxplot::Y_AXIS).line(plot_right_, plot_bottom_, plot_right_, plot_top_);
+ }
+ }
+
     path_element& minor_tick_path = image.g(boxplot::Y_MINOR_TICKS).path();
     path_element& major_tick_path = image.g(boxplot::Y_MAJOR_TICKS).path();
     path_element& major_grid_path = image.g(boxplot::Y_MAJOR_GRID).path();
@@ -1783,9 +1807,9 @@
 
   // Declarations of user boxplot functions.
 
- svg_boxplot& write(const std::string& file);
- svg_boxplot& write(std::ostream& s_out);
- svg_boxplot& title_on(bool cmd);
+ svg_boxplot& write(const std::string& file); // Write SVG plot to file.
+ svg_boxplot& write(std::ostream& s_out); // Write SVG plot to ostream.
+ svg_boxplot& title_on(bool cmd); // If to include title in plot.
   svg_boxplot& x_label_on(bool cmd);
   svg_boxplot& median_values_on(bool cmd);
   bool median_values_on();
@@ -1805,6 +1829,7 @@
   svg_boxplot& plot_background_color(const svg_color& col);
   svg_boxplot& plot_border_color(const svg_color& col);
   svg_boxplot& y_range(double min_y, double max_y);
+ std::pair<double, double> svg_boxplot::y_range();
   svg_boxplot& y_label(const std::string& str);
   svg_boxplot& image_size(unsigned int x, unsigned int y);
   svg_boxplot& y_label_font_size(unsigned int size);
@@ -1825,7 +1850,7 @@
   svg_boxplot& y_minor_tick_width(unsigned int width);
   unsigned int image_x_size();
   unsigned int image_y_size();
- std::string title();
+ std::string title(); // title assigned to boxplot.
   bool x_label_on();
   int x_major_labels();
   // get color information
@@ -1847,6 +1872,10 @@
   double whisker_length();
   svg_boxplot& box_width(double width); // Width of the box, not the border.
   double box_width(); // Width of the box, not the border.
+ svg_boxplot& x_axis_position(int pos); // Position of the horizontal X-axis line (on the border).
+ double x_axis_position(); // Position of the horizontal X-axis line (on the border).
+ svg_boxplot& y_axis_position(int pos); // Position of the vertical Y-axis line (on the border).
+ double y_axis_position(); // Position of the vertical Y-axis line (on the border).
   svg_boxplot& box_fill(const svg_color& color); // Color of box fill, not border.
   svg_color box_fill(); // Color of box fill, not border.
   svg_boxplot& box_border(const svg_color& color); // Color of border (not fill) to box.
@@ -1887,7 +1916,19 @@
   svg_boxplot& svg_boxplot::quartile_definition(int def); // H&F quartile definition.
   int svg_boxplot::quartile_definition(); // H&F quartile definition.
 
+ bool svg_boxplot::y_autoscale(); // If to use y_autoscaled values.
+ svg_boxplot& svg_boxplot::y_autoscale(bool b); // If to use y_autoscaled values.
+
+ svg_boxplot& svg_boxplot::y_autoscale(double first, double second);// Autoscale using two doubles.
 
+ svg_boxplot& svg_boxplot::y_autoscale(std::pair<double, double> p); // Autoscale using minmax pair of doubles.
+
+ template <class T> // T an STL container: array, vector ...
+ svg_boxplot& y_autoscale(const T& begin, const T& end); // Autoscale using iterators into container.
+ // explicit svg_boxplot::y_autoscale causes C2442 here, but omitting svg_boxplot:: is OK????
+
+ template <class T> // T an STL container: array, vector ...
+ svg_boxplot& y_autoscale(const T& container); //// Autoscale using whole container.
 
   // Plot member function to add a Data Series Boxplot.
 
@@ -2112,7 +2153,15 @@
     y_axis_.max_ = max_y;
     y_autoscale_ = false;
     return *this;
- } // svg_boxplot& y_range(double y1, double y2
+ } // svg_boxplot& y_range(double y1, double y2)
+
+ std::pair<double, double> svg_boxplot::y_range()
+ {
+ std::pair<double, double> r;
+ r.first = y_axis_.min_;
+ r.second = y_axis_.max_;
+ return r;
+ } // std::pair<double, double> svg_boxplot::y_range()
 
   svg_boxplot& svg_boxplot::y_label(const std::string& str)
   {
@@ -2149,6 +2198,31 @@
     return *this;
   }
 
+ svg_boxplot& svg_boxplot::x_axis_position(int pos)
+ { // Position of the horizontal X-axis line (on the border).
+ x_axis_position_ = pos; // top or bottom
+ // But controlled by the intersection with Y-axis,
+ // so this only changes the default position from bottom to top,
+ // but will be changed if X-axis intersects the Y-axis
+ // (that is if Y-axis includes zero).
+ return *this; // Make chainable.
+ }
+
+ double svg_boxplot::x_axis_position()
+ { // Position of the horizontal X-axis line (on the border).
+ return x_axis_position_; // top or bottom
+ }
+
+ svg_boxplot& svg_boxplot::y_axis_position(int pos)
+ { // Position of the vertical Y-axis line (on the border).
+ y_axis_position_ = pos; // left or right
+ return *this; // Make chainable.
+ }
+
+ double svg_boxplot::y_axis_position()
+ { // Position of the vertical Y-axis line (on the border).
+ return y_axis_position_; // left or right
+ }
 
   svg_boxplot& svg_boxplot::x_label(const std::string& str)
   {
@@ -2171,8 +2245,7 @@
   {
     y_ticks_.major_interval_ = inter;
     return *this;
- }
- svg_boxplot& svg_boxplot::x_tick_length(unsigned int length)
+ } svg_boxplot& svg_boxplot::x_tick_length(unsigned int length)
   {
     x_ticks_.major_tick_length_ = length;
     return *this;
@@ -2482,7 +2555,58 @@
     return quartile_definition_;
   }
 
+ bool svg_boxplot::y_autoscale()
+ {
+ return y_autoscale_;
+ }
+
+ svg_boxplot& svg_boxplot::y_autoscale(bool b)
+ {
+ y_autoscale_ = b;
+ return *this;
+ }
 
+ svg_boxplot& svg_boxplot::y_autoscale(std::pair<double, double> p)
+ { // Use Y min & max pair values to autoscale.
+ scale_axis(p.first, p.second, // double min and max from pair.
+ &y_auto_min_value_, &y_auto_max_value_, &y_auto_tick_interval_, &y_auto_ticks_,
+ autoscale_check_limits_,
+ y_include_zero_, y_tight_, y_min_ticks_, y_steps_);
+ y_autoscale_ = true; // Change (from default false) to use calculated values.
+ return *this; // Make chainable.
+ } // autoscale(pair<double, double> p)
+
+ svg_boxplot& svg_boxplot::y_autoscale(double first, double second)
+ { // Use Y min & max pair values to autoscale.
+ scale_axis(first, second, // double min and max from two doubles.
+ &y_auto_min_value_, &y_auto_max_value_, &y_auto_tick_interval_, &y_auto_ticks_,
+ autoscale_check_limits_,
+ y_include_zero_, y_tight_, y_min_ticks_, y_steps_);
+ y_autoscale_ = true; // Change (from default false) to use calculated values.
+ return *this; // Make chainable.
+ } // autoscale(pair<double, double> p)
+
+ template <class T> // T an STL container: array<double>, vector<double> ...
+ svg_boxplot& svg_boxplot::y_autoscale(const T& begin, const T& end) // Data series using iterators to
+ { // to use to calculate autoscaled values.
+ scale_axis(begin, end,
+ &y_auto_min_value_, &y_auto_max_value_, &y_auto_tick_interval_, &y_auto_ticks_,
+ autoscale_check_limits_,
+ y_include_zero_, y_tight_, y_min_ticks_, y_steps_);
+ y_autoscale_ = true; // Change (from default false) to use calculated values.
+ return *this; // Make chainable.
+ } // y_autoscale(const T& begin, const T& end)
+
+ template <class T> // T an STL container: array, vector ...
+ svg_boxplot& svg_boxplot::y_autoscale(const T& container) // Whole data series.
+ { // to use to calculate autoscaled values.
+ scale_axis(container.begin(), container.end(), // All the container.
+ &y_auto_min_value_, &y_auto_max_value_, &y_auto_tick_interval_, &y_auto_ticks_,
+ autoscale_check_limits_,
+ y_include_zero_, y_tight_, y_min_ticks_, y_steps_);
+ y_autoscale_ = true; // Change (from default false) to use calculated values.
+ return *this; // Make chainable.
+ } // y_autoscale(const T& container)
 
 
 #if defined (BOOST_MSVC)

Modified: sandbox/SOC/2007/visualization/boost/svg_plot/svg_style.hpp
==============================================================================
--- sandbox/SOC/2007/visualization/boost/svg_plot/svg_style.hpp (original)
+++ sandbox/SOC/2007/visualization/boost/svg_plot/svg_style.hpp 2008-06-18 07:18:41 EDT (Wed, 18 Jun 2008)
@@ -32,14 +32,16 @@
 {
 
 // Forward declarations of classes in svg_style.hpp
-class svg_style;
-class text_style;
-class value_style;
-class plot_point_style;
-class plot_line_style;
-class axis_line_style;
-class ticks_labels_style;
-class box_style;
+class svg_style; // Holds the basic stroke, fill colors and width, and their switches.
+class text_style; // Text font family, size ...
+class value_style; // Data series point value information, text, color, uncertainty & df, orientation.
+class plot_point_style; // Shape, color, (optional value & uncertainty) of data point markers.
+class plot_line_style; // Style of line joining data series values.
+class axis_line_style; // Style of the x and/or y axes lines. But NOT the ticks and value labels.
+class ticks_labels_style; // Style of the x and y axes ticks, grids and their value labels..
+class box_style; // Box colors, size and border switches.
+class histogram_style; // Options for histograms.
+class bar_style; // Style of bars.
 
 enum rotate_style
 { // Rotation in degrees from horizontal.
@@ -120,12 +122,14 @@
   void write(std::ostream& os); // Output to file or stream.
 
   // operators useful for testing at least.
+ // TODO add operator << ?
   bool operator==(svg_style& s);
   bool operator!=(svg_style& s);
 
 }; // class svg_style
 
 // class svg Definitions.
+// Constructors.
 
   svg_style::svg_style(const svg_color& stroke, const svg_color& fill, unsigned int width)
   :
@@ -143,6 +147,7 @@
   { // Default constructor initialises all private data.
   }
 
+ // Member Functions definitions.
   svg_color svg_style::fill_color() const
   {
     return svg_color(fill_);
@@ -274,7 +279,7 @@
   // End of svg_style definitions.
 
 class text_style
-{
+{ // text style - font family, size, weight, style, stretch, decoration.
   friend std::ostream& operator<< (std::ostream&, const text_style&);
   friend bool operator== (const text_style&, const text_style&);
   friend bool operator!= (const text_style&, const text_style&);
@@ -316,7 +321,7 @@
 
 }; // class text_style
 
-// class text_style function *Definitions* separated.
+// class text_style function *Definitions*.
 
   text_style::text_style(
     int size,
@@ -502,7 +507,16 @@
   bool df_on_; // If an degrees of freedom estimate is to be appended.
 
   public:
- value_style()
+ value_style();
+ value_style(rotate_style r, int p, std::ios_base::fmtflags f, bool s,
+ text_style ts, const svg_color& scol /* = black */, svg_color fcol, bool pm /*= false*/, bool df /*= false*/);
+
+}; // class value_style
+
+// class value_style Member Functions definitions.
+// Constructor.
+
+value_style::value_style()
     :
     value_label_rotation_(horizontal),
     value_precision_(3), // Reduced from default of 6 which is usually too long.
@@ -516,7 +530,7 @@
     { // Default constructor initialises all private data.
     }
 
- value_style(rotate_style r, int p, std::ios_base::fmtflags f, bool s,
+ value_style::value_style(rotate_style r, int p, std::ios_base::fmtflags f, bool s,
       text_style ts, const svg_color& scol = black, svg_color fcol = black, bool pm = false, bool df = false)
     :
     value_label_rotation_(r), value_precision_(p), value_ioflags_(f), strip_e0s_(s),
@@ -524,7 +538,7 @@
     { // Constructor.
     }
 
-}; // class value_style
+// End class value_style Member Functions definitions.
 
 enum point_shape
 { // Marking a data point.
@@ -560,7 +574,7 @@
 }; // enum point_shape
 
 class plot_point_style
-{
+{ // Shape, color, (optional value & uncertainty) of data point markers.
   friend std::ostream& operator<< (std::ostream&, plot_point_style);
 
 public:
@@ -586,7 +600,27 @@
   //text_style value_style_; // Size, font, color etc of the value.
 
   plot_point_style(const svg_color& stroke = black, const svg_color& fill = blank,
- int size = 10, point_shape shape = round, const std::string& symbols = "X")
+ int size = 10, point_shape shape = round, const std::string& symbols = "X");
+
+ plot_point_style& size(int i);
+ int size();
+ plot_point_style& fill_color(const svg_color& f);
+ svg_color& fill_color();
+ plot_point_style& stroke_color(const svg_color& f);
+ svg_color& stroke_color();
+ plot_point_style& shape(point_shape s);
+ point_shape shape();
+ plot_point_style& symbols(const std::string s);
+ std::string& symbols();
+ plot_point_style& style(text_style ts);
+ text_style& style() const;
+}; // struct plot_point_style
+
+// class plot_point_style function Definitions.
+// Constructor.
+
+ plot_point_style::plot_point_style(const svg_color& stroke, const svg_color& fill,
+ int size, point_shape shape, const std::string& symbols)
   :
     fill_color_(fill), stroke_color_(stroke), size_(size),
     shape_(shape), symbols_(symbols),
@@ -597,73 +631,76 @@
     symbols_style_.font_size(size);
   }
 
- plot_point_style& size(int i)
+// Member function Definitions.
+
+ plot_point_style& plot_point_style::size(int i)
   {
     size_ = i; // Shapes.
     symbols_style_.font_size(i); // In case using a symbol.
     return *this;
   }
 
- int size()
+ int plot_point_style::size()
   {
     return size_;
   }
 
- plot_point_style& fill_color(const svg_color& f)
+ plot_point_style& plot_point_style::fill_color(const svg_color& f)
   {
     fill_color_ = f;
     return *this;
   }
 
- svg_color& fill_color()
+ svg_color& plot_point_style::fill_color()
   {
     return fill_color_;
   }
 
- plot_point_style& stroke_color(const svg_color& f)
+ plot_point_style& plot_point_style::stroke_color(const svg_color& f)
   {
     stroke_color_ = f;
     return *this;
   }
 
- svg_color& stroke_color()
+ svg_color& plot_point_style::stroke_color()
   {
     return stroke_color_;
   }
 
- plot_point_style& shape(point_shape s)
+ plot_point_style& plot_point_style::shape(point_shape s)
   {
     shape_ = s;
     return *this;
   }
 
- point_shape shape()
+ point_shape plot_point_style::shape()
   {
     return shape_;
   }
 
- plot_point_style& symbols(const std::string s)
+ plot_point_style& plot_point_style::symbols(const std::string s)
   { // Override default symbol "X" - only effective if .shape(symbol) used.
     symbols_ = s;
     return *this;
   }
 
- std::string& symbols()
+ std::string& plot_point_style::symbols()
   {
     return symbols_;
   }
 
- plot_point_style& style(text_style ts)
+ plot_point_style& plot_point_style::style(text_style ts)
   {
     symbols_style_ = ts;
     return *this;
   }
 
- text_style& style() const
+ text_style& plot_point_style::style() const
   { // To allow control of symbol font, size, decoration etc.
     return const_cast<text_style&>(symbols_style_);
   }
-}; // struct plot_point_style
+
+// End class plot_point_style function *Definitions* separated.
 
 std::ostream& operator<< (std::ostream& os, plot_point_style p)
 { //
@@ -689,69 +726,89 @@
     double width_;
     bool line_on_;
     bool bezier_on_;
+ plot_line_style(const svg_color& col = black, const svg_color& fill_col = blank, double width = 2, bool line_on = true, bool bezier_on = false);
 
- plot_line_style(const svg_color& col = black, const svg_color& fill_col = blank, double width = 2, bool line_on = true, bool bezier_on = false)
+ plot_line_style& width(double w);
+ double width();
+ plot_line_style& color(const svg_color& f);
+ svg_color& color();
+ plot_line_style& area_fill(const svg_color& f);
+ svg_color& area_fill();
+ bool line_on() const;
+ plot_line_style& line_on(bool is) ;
+ bool bezier_on() const;
+ plot_line_style& bezier_on(bool is);
+
+}; // class plot_line_style
+
+// class plot_line_style function Definitions.
+
+// Constructor.
+ plot_line_style::plot_line_style(const svg_color& col, const svg_color& fill_col, double width, bool line_on, bool bezier_on)
     :
     stroke_color_(col), area_fill_(fill_col), width_(width), line_on_(line_on), bezier_on_(bezier_on)
     { // Defaults for all private data.
     }
 
- plot_line_style& width(double w)
+// Member Functions.
+
+ plot_line_style& plot_line_style::width(double w)
   {
     width_ = w;
     return *this; // Make chainable.
   }
 
- double width()
+ double plot_line_style::width()
   {
     return width_;
   }
 
- plot_line_style& color(const svg_color& f)
+ plot_line_style& plot_line_style::color(const svg_color& f)
   {
     stroke_color_ = f;
     return *this; // Make chainable.
   }
 
- svg_color& color()
+ svg_color& plot_line_style::color()
   {
     return stroke_color_;
   }
 
- plot_line_style& area_fill(const svg_color& f)
+ plot_line_style& plot_line_style::area_fill(const svg_color& f)
   {
     area_fill_ = f;
     return *this; // Make chainable.
   }
 
- svg_color& area_fill()
+ svg_color& plot_line_style::area_fill()
   {
     return area_fill_;
   }
 
- bool line_on() const
+ bool plot_line_style::line_on() const
   {
     return line_on_;
   }
 
- plot_line_style& line_on(bool is)
+ plot_line_style& plot_line_style::line_on(bool is)
   {
     line_on_ = is;
     return *this; // Make chainable.
   }
 
- bool bezier_on() const
+ bool plot_line_style::bezier_on() const
   {
     return bezier_on_;
   }
 
- plot_line_style& bezier_on(bool is)
+ plot_line_style& plot_line_style::bezier_on(bool is)
   {
     bezier_on_ = is;
     return *this; // Make chainable.
   }
 
-}; // class plot_line_style
+// End class plot_line_style function Definitions.
+
 
 std::ostream& operator<< (std::ostream& os, plot_line_style p)
 { //
@@ -794,13 +851,41 @@
   bool label_units_on_; // Label X-axis units, example: "cm".
   bool axis_line_on_; // Draw a X horizontal or Y vertical axis line.
 
+ // class axis_line_style constructor.
   axis_line_style(dim d = X,
- double min = -10., double max = +10., // Defaults.
+ double min = -10.,
+ double max = +10., // Defaults.
     // See also default in ticks_labels_style.
- const svg_color col = black, double width = 1,
- int axis_position = 0, bool label_on = true,
+ const svg_color col = black,
+ double width = 1,
+ int axis_position = 0,
+ bool label_on = true,
     bool label_units_on = false,
- bool axis_lines_on = true)
+ bool axis_lines_on = true);
+
+ // class axis_line_style member functions Declarations:
+ // Set and get member functions.
+ axis_line_style& color(const svg_color& color);
+ svg_color color();
+ axis_line_style& width(double w);
+ double width();
+ bool label_on() const;
+ axis_line_style& label_on(bool is) ;
+ bool label_units_on() const;
+ axis_line_style& label_units_on(bool is) ;
+ axis_line_style& position(int pos);
+ double position();
+}; // class axis_line_style
+
+// class axis_line_style Member Functions Definitions:
+
+ axis_line_style::axis_line_style(dim d,
+ double min, double max, // Defaults.
+ // See also default in ticks_labels_style.
+ const svg_color col, double width,
+ int axis_position, bool label_on,
+ bool label_units_on,
+ bool axis_lines_on)
     :
     dim_(d), min_(min), max_(max), color_(col), axis_width_(width),
     axis_position_(axis_position),
@@ -819,51 +904,63 @@
     }
  } // axis_line_style constructor
 
- // Set and get functions.
- axis_line_style& color(const svg_color& color)
+axis_line_style& axis_line_style::color(const svg_color& color)
   {
     color_ = color;
     return *this; // Make chainable.
   }
 
- svg_color color()
+ svg_color axis_line_style::color()
   {
     return color_;
   }
    
- axis_line_style& width(double w)
+ axis_line_style& axis_line_style::width(double w)
   {
     axis_width_ = w;
     return *this; // Make chainable.
   }
 
- double width()
+ double axis_line_style::width()
   {
     return axis_width_;
   }
 
- bool label_on() const
+ bool axis_line_style::label_on() const
   {
     return label_on_;
   }
 
- axis_line_style& label_on(bool is)
+ axis_line_style& axis_line_style::label_on(bool is)
   {
     label_on_ = is;
     return *this; // Make chainable.
   }
 
- bool label_units_on() const
+ bool axis_line_style::label_units_on() const
   {
     return label_units_on_;
   }
 
- axis_line_style& label_units_on(bool is)
+ axis_line_style& axis_line_style::label_units_on(bool is)
   {
     label_units_on_ = is;
     return *this; // Make chainable.
   }
-}; // class axis_line_style
+
+ axis_line_style& axis_line_style::position(int pos)
+ {
+ axis_position_ = pos;
+ return *this; // Make chainable.
+ }
+
+ double axis_line_style::position()
+ {
+ return axis_position_;
+ }
+
+
+// End class axis_line_style member functions definitions:
 
 
 class ticks_labels_style
@@ -1096,12 +1193,38 @@
     bool border_on_; // Display the border.
     bool fill_on_; // Color fill the box.
 
- box_style(const svg_color& scolor = black,
+ box_style(const svg_color& scolor = black,
       const svg_color& fcolor = white, // No fill.
       double width = 1, // of border
       double margin = 4., //
       bool border_on = true, // Draw a border of width.
- bool fill_on = false) // Apply fill color.
+ bool fill_on = false); // Apply fill color.
+
+ box_style& stroke(const svg_color& color);
+ svg_color stroke();
+ box_style& fill(const svg_color& color);
+ svg_color fill();
+ box_style& width(double w);
+ double width();
+ box_style& margin(double w);
+ double margin();
+ bool border_on() const;
+ box_style& border_on(bool is) ;
+ bool fill_on() const;
+ box_style& fill_on(bool is) ;
+
+}; // class box_style
+
+// class box_style Definitions.
+
+// Constructor.
+
+box_style::box_style(const svg_color& scolor, // = black,
+ const svg_color& fcolor, // = white, // No fill.
+ double width,// = 1, // of border
+ double margin, // = 4., //
+ bool border_on,// = true, // Draw a border of width.
+ bool fill_on) //= false) // Apply fill color.
       :
     stroke_(scolor), fill_(fcolor), width_(width),
     margin_(margin),
@@ -1110,73 +1233,76 @@
     { // Initializes all private data with defaults.
     }
 
- box_style& stroke(const svg_color& color)
+// Member Functions definitions.
+
+ box_style& box_style::stroke(const svg_color& color)
   {
     stroke_ = color;
     return *this; // Make chainable.
   }
 
- svg_color stroke()
+ svg_color box_style::stroke()
   {
     return stroke_;
   }
 
- box_style& fill(const svg_color& color)
+ box_style& box_style::fill(const svg_color& color)
   {
     fill_ = color;
     return *this; // Make chainable.
   }
 
- svg_color fill()
+ svg_color box_style::fill()
   {
     return fill_;
   }
 
- box_style& width(double w)
+ box_style& box_style::width(double w)
   {
     width_ = w;
     return *this; // Make chainable.
   }
 
- double width()
+ double box_style::width()
   {
     return width_;
   }
 
- box_style& margin(double w)
+ box_style& box_style::margin(double w)
   {
     margin_ = w;
     return *this; // Make chainable.
   }
 
- double margin()
+ double box_style::margin()
   {
     return margin_;
   }
 
- bool border_on() const
+ bool box_style::border_on() const
   {
     return border_on_;
   }
 
- box_style& border_on(bool is)
+ box_style& box_style::border_on(bool is)
   {
     border_on_ = is;
     return *this; // Make chainable.
   }
   
- bool fill_on() const
+ bool box_style::fill_on() const
   {
     return fill_on_;
   }
 
- box_style& fill_on(bool is)
+ box_style& box_style::fill_on(bool is)
   {
     fill_on_ = is;
     return *this; // Make chainable.
   }
 
-}; // class box_style
+// End class box_style Definitions.
+
 
 enum bar_option
 {
@@ -1199,29 +1325,40 @@
 };
 
 class histogram_style
-{
+{ // Options for histograms.
 public:
   histogram_option histogram_option_; // bar, no_histogram or column.
 
- histogram_style(histogram_option opt = no_histogram)
- :
- histogram_option_(opt)
- { // Default for all private data.
- // Line width and area-fill are taken from the plot_line_style style.
- }
+ histogram_style(histogram_option opt = no_histogram);
 
- histogram_style& histogram(histogram_option opt)
- { // stick or bar.
- histogram_option_ = opt;
- return *this; // Make chainable.
- }
+ histogram_style& histogram(histogram_option opt);
+ double histogram();
+}; // class histogram_style
 
- double histogram()
- { //
- return histogram_option_;
- }
 
-}; // class histogram_style
+// class histogram_style Definitions.
+
+// Constructor.
+histogram_style::histogram_style(histogram_option opt)
+:
+histogram_option_(opt)
+{ // Default for all private data.
+ // Line width and area-fill are taken from the plot_line_style style.
+}
+
+// Member Functions Definitions.
+
+histogram_style& histogram_style::histogram(histogram_option opt)
+{ // stick or bar.
+ histogram_option_ = opt;
+ return *this; // Make chainable.
+}
+
+double histogram_style::histogram()
+{ //
+ return histogram_option_;
+}
+// End class histogram_style Definitions.
 
 class bar_style
 { // TODO should inherit from svg_style?
@@ -1231,57 +1368,76 @@
   double width_; // of bar, not enclosing line width.
   bar_option bar_option_; // stick or bar.
 
- bar_style(const svg_color& col = black, const svg_color& acol = true, double width = 2, bar_option opt = no_bar)
- :
- color_(col), area_fill_(acol), width_(width), bar_option_(opt)
- { // Defaults for all private data.
- }
-
- bar_style& width(double w)
- { // of bar, not the enclosing line (stroke) width.
- width_ = w;
- return *this; // Make chainable.
- }
-
- double width()
- { // of bar, not enclosing line width.
- return width_;
- }
-
- bar_style& color(const svg_color& f)
- { // of line or enclosing line.
- color_ = f;
- return *this; // Make chainable.
- }
+ bar_style(const svg_color& col = black, const svg_color& acol = true, double width = 2, bar_option opt = no_bar);
+ bar_style& width(double w);
+ double width();
+ bar_style& color(const svg_color& f);
+ svg_color& color();
+ bar_style& area_fill(const svg_color& f);
+ svg_color& area_fill();
+ bar_style& bar_opt(bar_option option);
+ double bar_opt();
 
- svg_color& color()
- { // of line or enclosing line.
- return color_;
- }
+}; // class bar_style
 
- bar_style& area_fill(const svg_color& f)
- { // rectangle fill color.
- area_fill_ = f;
- return *this; // Make chainable.
- }
+// class bar_style Definitions.
 
- svg_color& area_fill()
- { // rectangle fill color.
- return area_fill_;
- }
+// Constructor.
 
- bar_style& bar(bar_option option)
- { // stick or bar.
- bar_option_ = option;
- return *this; // Make chainable.
- }
+bar_style::bar_style(const svg_color& col, const svg_color& acol, double width, bar_option opt)
+:
+color_(col), area_fill_(acol), width_(width), bar_option_(opt)
+{ // Defaults for all private data.
+}
+
+// Member Functions Definitions.
+
+bar_style& bar_style::width(double w)
+{ // of bar, not the enclosing line (stroke) width.
+ width_ = w;
+ return *this; // Make chainable.
+}
+
+double bar_style::width()
+{ // of bar, not enclosing line width.
+ return width_;
+}
+
+bar_style& bar_style::color(const svg_color& f)
+{ // of line or enclosing line.
+ color_ = f;
+ return *this; // Make chainable.
+}
+
+svg_color& bar_style::color()
+{ // of line or enclosing line.
+ return color_;
+}
+
+bar_style& bar_style::area_fill(const svg_color& f)
+{ // rectangle fill color.
+ area_fill_ = f;
+ return *this; // Make chainable.
+}
+
+svg_color& bar_style::area_fill()
+{ // rectangle fill color.
+ return area_fill_;
+}
+
+bar_style& bar_style::bar_opt(bar_option option)
+{ // stick or bar.
+ bar_option_ = option;
+ return *this; // Make chainable.
+}
+
+double bar_style::bar_opt()
+{ // stick or bar.
+ return bar_option_;
+}
 
- double bar_option()
- { // stick or bar.
- return bar_option_;
- }
+// End class bar_style Member Functions Definitions.
 
-}; // class bar_style
 
 const std::string strip_e0s(std::string s);
 

Modified: sandbox/SOC/2007/visualization/libs/svg_plot/example/auto_2d_plot.cpp
==============================================================================
--- sandbox/SOC/2007/visualization/libs/svg_plot/example/auto_2d_plot.cpp (original)
+++ sandbox/SOC/2007/visualization/libs/svg_plot/example/auto_2d_plot.cpp 2008-06-18 07:18:41 EDT (Wed, 18 Jun 2008)
@@ -86,7 +86,6 @@
         my_map[999.] = +numeric_limits<double>::infinity();
 
 
-
   /*`Next a 2D plot is created using defaults for the very many possible settings.
   */
         svg_2d_plot my_plot;
@@ -99,6 +98,7 @@
   //my_plot.autoscale_check_limits(false); // Skip checks for speed.
   // Will fail at run-time if any infinite or NaNs.
 
+ // my_plot.y_autoscale(0., 9.); // autoscale using two doubles.
         my_plot.xy_autoscale(my_map);
 
         my_plot.plot(my_map);

Modified: sandbox/SOC/2007/visualization/libs/svg_plot/example/demo_2d_bars.cpp
==============================================================================
--- sandbox/SOC/2007/visualization/libs/svg_plot/example/demo_2d_bars.cpp (original)
+++ sandbox/SOC/2007/visualization/libs/svg_plot/example/demo_2d_bars.cpp 2008-06-18 07:18:41 EDT (Wed, 18 Jun 2008)
@@ -36,9 +36,9 @@
                .x_range(-1, 11)
                .background_border_color(black);
 
- my_plot1.plot(map1, "Series 1").fill_color(blue).shape(none).line_on(false).bar(x_stick).bar_width(5).bar_color(red);
+ my_plot1.plot(map1, "Series 1").fill_color(blue).shape(none).line_on(false).bar_opt(x_stick).bar_width(5).bar_color(red);
   my_plot1.write("./demo_2d_bar_x_stick.svg");
- my_plot1.plot(map1, "Series 1").shape(none).line_on(false).bar(x_block).bar_width(10);
+ my_plot1.plot(map1, "Series 1").shape(none).line_on(false).bar_opt(x_block).bar_width(10);
   my_plot1.write("./demo_2d_bar_x_block.svg");
 
         svg_2d_plot my_plot2;
@@ -48,9 +48,9 @@
                .x_range(-10, 10)
                .background_border_color(blue);
 
- my_plot2.plot(map2, "Series 2").fill_color(green).shape(none).line_on(false).bar(y_stick).bar_width(5).bar_color(cyan);
+ my_plot2.plot(map2, "Series 2").fill_color(green).shape(none).line_on(false).bar_opt(y_stick).bar_width(5).bar_color(cyan);
   my_plot2.write("./demo_2d_bar_y_stick.svg");
- my_plot2.plot(map2, "Series 2").shape(none).line_on(false).bar(y_block).bar_width(10).bar_color(green).bar_area_fill(magenta);
+ my_plot2.plot(map2, "Series 2").shape(none).line_on(false).bar_opt(y_block).bar_width(10).bar_color(green).bar_area_fill(magenta);
   my_plot2.write("./demo_2d_bar_y_block.svg");
 
         return 0;

Modified: sandbox/SOC/2007/visualization/libs/svg_plot/test/1d_tests.cpp
==============================================================================
--- sandbox/SOC/2007/visualization/libs/svg_plot/test/1d_tests.cpp (original)
+++ sandbox/SOC/2007/visualization/libs/svg_plot/test/1d_tests.cpp 2008-06-18 07:18:41 EDT (Wed, 18 Jun 2008)
@@ -163,7 +163,7 @@
   BOOST_CHECK_EQUAL(tl2.second, 20.);
 
   BOOST_CHECK_EQUAL(my_plot.title(), "Plot of data"); // Title of plot.
- my_plot.title("test");
+ my_plot.title("Plot of data");
   BOOST_CHECK_EQUAL(my_plot.title(), "test");
 
   BOOST_CHECK_EQUAL(my_plot.legend_title(), ""); // Default no legend title.
@@ -292,7 +292,7 @@
 
   my_plot.y_axis_on(false); // But leave false - as always should be for 1D?
 
- BOOST_CHECK_EQUAL(my_plot.title_color(), svg_color(0, 0, 0)); // Check default color.
+ BOOST_CHECK_EQUAL(my_plot.title_color(), blank); // Check default color.
   my_plot.title_color(svg_color(red)); //
          BOOST_CHECK_EQUAL(my_plot.title_color(), svg_color(red)); // & check.
 
@@ -324,11 +324,11 @@
   my_plot.y_axis_color( svg_color(red)); //
          BOOST_CHECK_EQUAL(my_plot.y_axis_color(), svg_color(red)); // & check.
 
- BOOST_CHECK_EQUAL(my_plot.x_label_color(), svg_color(black)); // Check default color.
+ BOOST_CHECK_EQUAL(my_plot.x_label_color(), blank); // Check default color.
   my_plot.x_label_color( svg_color(red)); //
          BOOST_CHECK_EQUAL(my_plot.x_label_color(), svg_color(red)); // & check.
 
- BOOST_CHECK_EQUAL(my_plot.y_label_color(), svg_color(black)); // Check default color.
+ BOOST_CHECK_EQUAL(my_plot.y_label_color(), blank); // Check default color.
   my_plot.y_label_color(svg_color(red)); //
          BOOST_CHECK_EQUAL(my_plot.y_label_color(), svg_color(red)); // & check.
 
@@ -361,12 +361,12 @@
          BOOST_CHECK_EQUAL(my_plot.x_axis_width(), 2); // & check.
 
          BOOST_CHECK_EQUAL(my_plot.x_label(), "X Axis"); // Check default label.
- my_plot.x_label("X"); //
+ my_plot.x_label("X Axis"); //
          BOOST_CHECK_EQUAL(my_plot.x_label(), "X"); // & check.
          BOOST_CHECK_EQUAL(my_plot.x_label(), "X"); // & check.
 
          BOOST_CHECK_EQUAL(my_plot.x_label_units(), " (units)"); // Check default label.
- my_plot.x_label_units(" (meter)"); //
+ my_plot.x_label_units(" (units)"); //
          BOOST_CHECK_EQUAL(my_plot.x_label_units()," (meter)"); // & check.
 
          BOOST_CHECK_EQUAL(my_plot.x_major_interval(), 2.); // Check default.


Boost-Commit list run by bdawes at acm.org, david.abrahams at rcn.com, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk