Boost C++ Libraries Home Libraries People FAQ More

PrevUpHomeNext

svg_2d_plot Public Interface

Miscellaneous
Commands
Axis Information
The plot() Method

Miscellaneous

Signature Description
svg_2d_plot() See the defaults section for further details
svg_2d_plot& image_size(unsigned int, unsigned int) Sets the size of the image produced, in pixels
svg_2d_plot& title(const std::string&) Sets the string to be used for the title
svg_2d_plot& title_font_size(unsigned int) Sets the font size for the title
svg_2d_plot& legend_title_font_size(unsigned int) Sets the font size for the legend title

Commands

Signature Description
svg_2d_plot& axis_on(bool) Sets whether the axis is on or off
svg_2d_plot& legend_on(bool) Sets whether the legend is on or off
svg_2d_plot& plot_window_on(bool) Sets whether the plot will be displayed in its own window, or will be "full screen" in the image
svg_2d_plot& title_on(bool) Determines whether or not the image title is displayed
svg_2d_plot& x_label_on(bool) Sets whether or not the X axis label will show
svg_2d_plot& x_major_grid_on(bool) Determines whether or not the major grid on the X axis will be displayed
svg_2d_plot& x_major_labels_on(bool) sets whether or not the major ticks will be labelled on the x axis
svg_2d_plot& x_minor_grid_on(bool) Determines whether or not the minor grid on the X axis will be displayed
svg_2d_plot& y_label_on(bool) Sets whether or not the Y axis label will show
svg_2d_plot& y_major_grid_on(bool) Determines whether or not the major grid on the Y axis will be displayed
svg_2d_plot& y_major_labels_on(bool) sets whether or not the major ticks will be labelled on the Y axis
svg_2d_plot& y_minor_grid_on(bool) Determines whether or not the minor grid on the Y axis will be displayed

Signature Description
svg_2d_plot& title_color(const svg_color &col) Set the title color
svg_2d_plot& background_color(const svg_color &col) Set the background color for the whole image
svg_2d_plot& legend_background_color(const svg_color &col) Set the background color for the legend as col, an RGB color
svg_2d_plot& legend_border_color(const svg_color &col) Set the border color for the legend as col, an RGB color
svg_2d_plot& background_border_color(const svg_color &col) Set the background border color for the legend as col, an RGB color
svg_2d_plot& plot_background_color(const svg_color &col) Set the color of the plot area. Note: this only goes into effect if plot_area(true) has been called
svg_2d_plot& x_axis_color(const svg_color &col) Sets the color of the lines that form the axis
svg_2d_plot& x_label_color(const svg_color &col) Sets the color of the labels that go along the X axis
svg_2d_plot& x_major_tick_color(const svg_color &col) Sets the color of the major ticks of the x-axis
svg_2d_plot& x_major_grid_color(const svg_color &col) Sets the color of the grid that runs perpindicular to the X axis
svg_2d_plot& x_minor_tick_color(const svg_color &col) Sets the color of the minor ticks of the x-axis
svg_2d_plot& y_axis_color(const svg_color &col) Sets the color of the lines that form the Y axis
svg_2d_plot& y_label_color(const svg_color &col) Sets the color of the labels that go along the X axis
svg_2d_plot& y_major_tick_color(const svg_color &col) Sets the color of the major ticks of the Y-axis
svg_2d_plot& y_major_grid_color(const svg_color &col) Sets the color of the grid that runs perpindicular to the Y axis
svg_2d_plot& y_minor_tick_color(const svg_color &col) Sets the color of the minor ticks of the Y-axis

Axis Information

Signature Description
svg_2d_plot& x_axis_width(unsigned int) Sets the stroke width of the x-axis
svg_2d_plot& x_label(const std::string&) Sets the label of the x-axis. This does not guarantee that it will be shown. You must run x_label(true) for that guarantee
svg_2d_plot& x_major_interval(double) Sets the distance (in Cartesian units) between ticks on the x-axis
svg_2d_plot& x_major_tick_length(int) Sets the length (in pixels) of the x-axis major ticks
svg_2d_plot& x_major_tick_width(unsigned int) Sets the width (in pixels) of the major ticks on the x-axis
svg_2d_plot& x_minor_tick(unsigned int) Sets the length (in pixels) of the x-axis minor ticks
svg_2d_plot& x_minor_tick_length(int) Sets the length (in pixels) of the x-axis minor tick lengths
svg_2d_plot& x_minor_tick_width(unsigned int) Sets the width (in pixels) of the minor ticks on the x-axis
svg_2d_plot& x_num_minor_ticks(int) Sets the number of minor ticks between each major tick
svg_2d_plot& x_range(double x1, double x2) Sets the scale of the x axis from x1 to x2. Throws an exception if x2<=x1
svg_2d_plot& y_axis_width(unsigned int) Sets the stroke width of the x-axis
svg_2d_plot& y_label(const std::string&) Sets the label of the x-axis. This does not guarantee that it will be shown. You must run x_label(true) for that guarantee
svg_2d_plot& y_major_tick(double) Sets the distance (in Cartesian units) between ticks on the Y axis
svg_2d_plot& y_major_tick_length(int) Sets the length (in pixels) of the Y axis major ticks
svg_2d_plot& y_major_tick_width(unsigned int) Sets the width (in pixels) of the major ticks on the Y axis
svg_2d_plot& y_minor_tick(unsigned int) Sets the length (in pixels) of the Y axis minor ticks
svg_2d_plot& y_major_tick_length(int) Sets the length (in pixels) of the Y axis minor tick lengths
svg_2d_plot& y_minor_tick_width(unsigned int) Sets the width (in pixels) of the minor ticks on the Y axis
svg_2d_plot& y_num_minor_ticks(int) Sets the number of minor ticks between each major tick
svg_2d_plot& y_scale(double y1, double y2) Sets the scale of the Y axis from y1 to y2. Throws an exception if y2<=y1

(Note: Getters omitted for now)

The plot() Method

The plot() method is defined using Boost.Parameter. As such, it supports a few extra named parameters, as well as a deduced parameter.

Required parameter

ID Type (* is a wildcard) Description
_container * Any object that can return an iterator with begin() and end()
_title std::string The name of this series

Deduced parameter

ID Type Description Default
_fill_color svg_color This is the color that shows up inside of the circle that is being drawn white

Optional Parameters

ID Type Description Default
_bezier_on bool This determines whether or not Bézier curve interpolation will be applied to the plot lines. It is important to note that the curve interpolation is still in its infancy, and should only be used with reasonably nice data sets  
_line_on bool This determines whether or not there are lines drawn between data points. false
_line_color bool This determines the color of the lines between data points black
_area_fill_color svg_color Defining this enables the "Fill Area Under Axis" feature. the color you define will be the fill color between a line and the area under the axis. This only takes effect if _line_on = true is called.  
_stroke_color svg_color The outline of the circle that is being drawn black
_point_style point_shape This is the shape of the point. Options currently are between none, circle, and square. circle
_size unsigned int This is the height/width of the circle and square. 10
_x_functor * A class or that contains a conversion function. You will not have to worry about this, unless you are trying to accomplish stuff like plotting a vector of humans. For example:
class my_functor
{
	typdef pair<double, double> result_type;

	pair<double, double> operator()(const human& _hum) const
	{
		return pair<double, double>(i, _hum.age());
	}
}

// snip

plot(my_plot, my_data, "Lions", _x_functor = my_functor());
boost_default_2d_convert (the default) is sufficient in all cases where the data stored in the container can be directly casted to a double

Here are some examples of correct uses:

Using fill and stroke colors

my_plot.(my_data, "Lions", 
_fill_color = red, 
_stroke_color = black);

This has the same effect as the following:

my_plot.plot(my_data, "Lions", red, black);

and also the same effect as:

my_plot.plot(my_data, "Lions", 
_stroke_color = black,  
_fill_color = red);

Since _fill_color is a deduced parameter, when two svg_colors are used in the same function call, they are always inferred in the following order: (fill, stroke).

Copyright © 2007 Jake Voytko

PrevUpHomeNext