Boost C++ Libraries Home Libraries People FAQ More

PrevUpHomeNext

svg_1d_plot Public Interface

Miscellaneous Functions
Commands
Color Information
Axis Information
The plot() Method

Miscellaneous Functions

Signature Description
svg_1d_plot() See the defaults section for further details
svg_1d_plot& image_size(unsigned int, unsigned int) Sets the size of the image produced, in pixels
svg_1d_plot& legend_title_font_size(unsigned int) Sets the font size for the legend title
svg_1d_plot& title(const std::string&) Sets the string to be used for the title
svg_1d_plot& title_font_size(unsigned int) Sets the font size for the title
svg_1d_plot& write(const std::string&) Writes the plot to the file passed as a parameter
svg_1d_plot& write(ostream&) Writes the plot to a stream passed as a parameter

Commands

Signature Description
svg_1d_plot& axis_on(bool) Sets whether the axis is on or off
svg_1d_plot& legend_on(bool) Sets whether the legend is on or off
svg_1d_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_1d_plot& title_on(bool) Determines whether or not the image title is displayed
svg_1d_plot& x_axis_on(bool) Determines whether or not the X axis is displayed
svg_1d_plot& x_external_style_on(bool) Determines whether or not the axis is inside or outside of the plot. Defaults to false
svg_1d_plot& x_label_on(bool) Sets whether or not the x axis label will show
svg_1d_plot& x_major_labels_on(bool) sets whether or not the major ticks will be labelled on the x axis
svg_1d_plot& x_major_grid_on(bool) Determines whether or not the major grid on the X axis will be displayed
svg_1d_plot& x_minor_grid_on(bool) Determines whether or not the minor grid on the X axis will be displayed
svg_1d_plot& y_axis_on(bool) Determines whether or not the Y axis is displayed

Color Information

Signature Description
svg_1d_plot& background_border_color(const svg_color &col) Set the background border color for the legend as col, an RGB color
svg_1d_plot& background_color(const svg_color &col) Set the background color for the whole image
svg_1d_plot& legend_background_color(const svg_color &col) Set the background color for the legend as col, an RGB color
svg_1d_plot& legend_border_color(const svg_color &col) Set the border color for the legend as col, an RGB color
svg_1d_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_1d_plot& title_color(const svg_color &col) Set the title color
svg_1d_plot& x_axis_color(const svg_color &col) Sets the color of the lines that form the axis
svg_1d_plot& x_label_color(const svg_color &col) Sets the color of the labels that go along the X axis
svg_1d_plot& x_major_grid_color(const svg_color &col) Sets the color of the grid that runs perpindicular to the X axis
svg_1d_plot& x_major_tick_color(const svg_color &col) Sets the color of the major ticks of the x-axis
svg_1d_plot& x_minor_grid_color(const svg_color &col) Sets the color of the minor grid of the x-axis
svg_1d_plot& x_minor_tick_color(const svg_color &col) Sets the color of the minor ticks of the x-axis

Axis Information

Signature Description
svg_1d_plot& x_axis_width(unsigned int) Sets the stroke width of the x-axis
svg_1d_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_on(true) for that guarantee
svg_1d_plot& x_major_interval(double) Sets the distance (in Cartesian units) between ticks on the x-axis
svg_1d_plot& x_major_tick_length(int) Sets the length (in pixels) of the x-axis major ticks
svg_1d_plot& x_major_tick_width(unsigned int) Sets the width (in pixels) of the major ticks on the x-axis
svg_1d_plot& x_minor_tick_length(int) Sets the length (in pixels) of the x-axis minor tick lengths
svg_1d_plot& x_minor_tick_width(unsigned int) Sets the width (in pixels) of the minor ticks on the x-axis
svg_1d_plot& x_num_minor_ticks(int) Sets the number of minor ticks between each major tick
svg_1d_plot& x_range(double x1, double x2) Sets the scale of the x axis from x1 to x2. Throws an exception if x2<=x1

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
_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 double result_type;

	double operator()(const human& _hum)
	{
		return (double)(_hum.age());
	}
}

// snip

plot(my_plot, my_data, "Lions", _x_functor = my_functor());
boost_default_convert 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.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