Boost logo

Boost-Commit :

From: JakeVoytko_at_[hidden]
Date: 2007-07-28 20:42:57


Author: jakevoytko
Date: 2007-07-28 20:42:53 EDT (Sat, 28 Jul 2007)
New Revision: 7576
URL: http://svn.boost.org/trac/boost/changeset/7576

Log:
Examples added
Added:
   sandbox/SOC/2007/visualization/libs/svg_plot/example/
   sandbox/SOC/2007/visualization/libs/svg_plot/example/1d_full_layout.cpp (contents, props changed)
   sandbox/SOC/2007/visualization/libs/svg_plot/example/1d_simple.cpp (contents, props changed)
   sandbox/SOC/2007/visualization/libs/svg_plot/example/1d_x_external.cpp (contents, props changed)
   sandbox/SOC/2007/visualization/libs/svg_plot/example/1d_x_grid.cpp (contents, props changed)
   sandbox/SOC/2007/visualization/libs/svg_plot/example/2d_area_fill.cpp (contents, props changed)
   sandbox/SOC/2007/visualization/libs/svg_plot/example/2d_full.cpp (contents, props changed)
   sandbox/SOC/2007/visualization/libs/svg_plot/example/2d_simple.cpp (contents, props changed)
   sandbox/SOC/2007/visualization/libs/svg_plot/example/2d_y_grid.cpp (contents, props changed)

Added: sandbox/SOC/2007/visualization/libs/svg_plot/example/1d_full_layout.cpp
==============================================================================
--- (empty file)
+++ sandbox/SOC/2007/visualization/libs/svg_plot/example/1d_full_layout.cpp 2007-07-28 20:42:53 EDT (Sat, 28 Jul 2007)
@@ -0,0 +1,87 @@
+// 1d_full_layout.cpp
+// Copyright (C) Jacob Voytko 2007
+// Distributed under the Boost Software License, Version 1.0.
+// For more information, see http://www.boost.org
+// -----------------------------------------------------------------
+#include <boost/svg_plot/svg_1d_plot.hpp>
+#include <vector>
+#include <deque>
+#include <cmath>
+#include <boost/array.hpp>
+
+using std::vector;
+using std::deque;
+using namespace boost::svg;
+
+double f(double x)
+{
+ return sqrt(x);
+}
+
+double g(double x)
+{
+ return -2 + x*x;
+}
+
+double h(double x)
+{
+ return -1 + 2*x;
+}
+
+int main()
+{
+ vector<double> data1;
+ deque<double> data2;
+ boost::array<double, 10> data3;
+
+ int j=0;
+ for(double i=0; i<9.5; i+=1.)
+ {
+ data1.push_back(f(i));
+ data2.push_front(g(i));
+ data3[j++] = h(i);
+ }
+
+ svg_1d_plot my_plot;
+
+ // Size/scale settings.
+ my_plot.image_size(500, 350)
+ .x_range(-3, 10);
+
+ // Text settings.
+ my_plot.title("Oh My!")
+ .title_font_size(29)
+ .x_label("Time in Months");
+
+ // Commands.
+ my_plot.legend_on(true)
+ .plot_window_on(true)
+ .x_label_on(true)
+ .x_major_labels_on(true);
+
+ // color settings
+ my_plot.background_color(svg_color(67, 111, 69))
+ .legend_background_color(svg_color(207, 202,167))
+ .legend_border_color(svg_color(102, 102, 84))
+ .plot_background_color(svg_color(136, 188, 126))
+ .title_color(white);
+
+ //axis settings
+ my_plot.x_major_tick(2)
+ .x_major_tick_length(14)
+ .x_major_tick_width(1)
+ .x_minor_tick_length(7)
+ .x_minor_tick_width(1)
+ .x_num_minor_ticks(3);
+
+ //legend settings
+ my_plot.legend_title_font_size(15);
+
+ my_plot.plot(data1, "Lions", blue);
+ my_plot.plot(data2, "Tigers", orange);
+ my_plot.plot(data3, "Bears", red);
+
+ my_plot.write("D:\\1d_complex.svg");
+
+ return 0;
+}

Added: sandbox/SOC/2007/visualization/libs/svg_plot/example/1d_simple.cpp
==============================================================================
--- (empty file)
+++ sandbox/SOC/2007/visualization/libs/svg_plot/example/1d_simple.cpp 2007-07-28 20:42:53 EDT (Sat, 28 Jul 2007)
@@ -0,0 +1,35 @@
+// 1d_simple.cpp
+// Copyright (C) Jacob Voytko 2007
+// Distributed under the Boost Software License, Version 1.0.
+// For more information, see http://www.boost.org
+// -----------------------------------------------------------------
+
+#include <boost/svg_plot/svg_1d_plot.hpp>
+#include <vector>
+
+using std::vector;
+using namespace boost::svg;
+
+int main()
+{
+ vector<double> dan_times;
+ vector<double> elaine_times;
+
+ dan_times.push_back(3.1);
+ dan_times.push_back(4.2);
+ elaine_times.push_back(2.1);
+ elaine_times.push_back(7.8);
+
+ svg_1d_plot my_plot;
+
+ my_plot.background_border_color(black)
+ .legend_on(true)
+ .title("Race Times")
+ .x_range(-1, 11);
+
+ my_plot.plot(dan_times, "Dan", blue);
+ my_plot.plot(elaine_times, "Elaine", orange);
+
+ my_plot.write("D:\\1d_simple.svg");
+ return 0;
+}

Added: sandbox/SOC/2007/visualization/libs/svg_plot/example/1d_x_external.cpp
==============================================================================
--- (empty file)
+++ sandbox/SOC/2007/visualization/libs/svg_plot/example/1d_x_external.cpp 2007-07-28 20:42:53 EDT (Sat, 28 Jul 2007)
@@ -0,0 +1,50 @@
+// 1d_x_external.cpp
+// Copyright (C) Jacob Voytko 2007
+// Distributed under the Boost Software License, Version 1.0.
+// For more information, see http://www.boost.org
+// -----------------------------------------------------------------
+
+#include <boost/svg_plot/svg_1d_plot.hpp>
+#include <vector>
+
+using std::vector;
+using namespace boost::svg;
+
+int main()
+{
+ vector<double> dan_times;
+ vector<double> elaine_times;
+
+ dan_times.push_back(3.1);
+ dan_times.push_back(4.2);
+ elaine_times.push_back(2.1);
+ elaine_times.push_back(7.8);
+
+ svg_1d_plot my_plot;
+
+ // Adding generic settings.
+ my_plot.background_border_color(black)
+ .legend_on(true)
+ .plot_window_on(true)
+ .title("Race Times")
+ .x_range(-1, 11);
+
+ // Adding grid information.
+ my_plot.x_major_grid_on(true)
+ .x_minor_grid_on(true);
+
+
+ // Styling grid.
+ my_plot.x_major_grid_color(black)
+ .x_minor_grid_color(lightgray);
+
+ my_plot.x_external_style_on(true);
+
+ // Write to plot.
+ my_plot.plot(dan_times, "Dan", blue);
+ my_plot.plot(elaine_times, "Elaine", orange);
+
+ // Write to file.
+ my_plot.write("D:\\1d_x_external.svg");
+ return 0;
+}

Added: sandbox/SOC/2007/visualization/libs/svg_plot/example/1d_x_grid.cpp
==============================================================================
--- (empty file)
+++ sandbox/SOC/2007/visualization/libs/svg_plot/example/1d_x_grid.cpp 2007-07-28 20:42:53 EDT (Sat, 28 Jul 2007)
@@ -0,0 +1,48 @@
+// 1d_x_grid.cpp
+// Copyright (C) Jacob Voytko 2007
+// Distributed under the Boost Software License, Version 1.0.
+// For more information, see http://www.boost.org
+// -----------------------------------------------------------------
+
+#include <boost/svg_plot/svg_1d_plot.hpp>
+#include <vector>
+
+using std::vector;
+using namespace boost::svg;
+
+int main()
+{
+ vector<double> dan_times;
+ vector<double> elaine_times;
+
+ dan_times.push_back(3.1);
+ dan_times.push_back(4.2);
+ elaine_times.push_back(2.1);
+ elaine_times.push_back(7.8);
+
+ svg_1d_plot my_plot;
+
+ // Adding generic settings.
+ my_plot.background_border_color(black)
+ .legend_on(true)
+ .plot_window_on(true)
+ .title("Race Times")
+ .x_range(-1, 11);
+
+ // Adding grid information.
+ my_plot.x_major_grid_on(true)
+ .x_minor_grid_on(true);
+
+
+ // Styling grid.
+ my_plot.x_major_grid_color(black)
+ .x_minor_grid_color(lightgray);
+
+ // WRite to plot.
+ my_plot.plot(dan_times, "Dan", blue);
+ my_plot.plot(elaine_times, "Elaine", orange);
+
+ // Write to file.
+ my_plot.write("D:\\1d_x_grid.svg");
+ return 0;
+}

Added: sandbox/SOC/2007/visualization/libs/svg_plot/example/2d_area_fill.cpp
==============================================================================
--- (empty file)
+++ sandbox/SOC/2007/visualization/libs/svg_plot/example/2d_area_fill.cpp 2007-07-28 20:42:53 EDT (Sat, 28 Jul 2007)
@@ -0,0 +1,79 @@
+// 2d_area_fill.cpp
+// Copyright (C) Jacob Voytko 2007
+// Distributed under the Boost Software License, Version 1.0.
+// For more information, see http://www.boost.org
+// -----------------------------------------------------------------
+
+#include <boost/svg_plot/svg_2d_plot.hpp>
+#include <map>
+#include <cmath>
+
+using std::map;
+using namespace boost::svg;
+
+double f(double x)
+{
+ return 50. * sin(x);
+}
+
+int main()
+{
+ map<double, double> data1;
+
+ double inter = 3.14159265 / 8.;
+
+ for(double i=0; i<=10.; i+=inter)
+ {
+ data1[i] = f(i);
+ }
+
+ svg_2d_plot my_plot;
+
+ // Size/scale settings.
+ my_plot.image_size(700, 500)
+ .x_range(-1, 10)
+ .y_range(-75, 75);
+
+
+ // Text settings.
+ my_plot.title("Plot of 50 * sin(x)")
+ .title_font_size(29)
+ .x_label("X Axis Units")
+ .y_major_labels_on(true)
+ .y_major_grid_on(true);
+
+ // Commands.
+ my_plot.plot_window_on(true)
+ .x_label_on(true)
+ .x_major_labels_on(true);
+
+ // Color settings.
+ my_plot.background_color(svg_color(67, 111, 69))
+ .legend_background_color(svg_color(207, 202,167))
+ .legend_border_color(svg_color(102, 102, 84))
+ .plot_background_color(svg_color(136, 188, 126))
+ .title_color(white)
+ .y_major_grid_color(black);
+
+ //X axis settings.
+ my_plot.x_major_tick(2)
+ .x_major_tick_length(14)
+ .x_major_tick_width(1)
+ .x_minor_tick_length(7)
+ .x_minor_tick_width(1)
+ .x_num_minor_ticks(3)
+
+ //Y axis settings.
+ .y_major_interval(25)
+ .y_num_minor_ticks(5);
+
+ //legend settings
+ my_plot.legend_title_font_size(15);
+
+ my_plot.plot(data1, "Sqrt(x)", _point_style = none,
+ _area_fill_color = red);
+
+ my_plot.write("D:\\2d_area_fill.svg");
+
+ return 0;
+}

Added: sandbox/SOC/2007/visualization/libs/svg_plot/example/2d_full.cpp
==============================================================================
--- (empty file)
+++ sandbox/SOC/2007/visualization/libs/svg_plot/example/2d_full.cpp 2007-07-28 20:42:53 EDT (Sat, 28 Jul 2007)
@@ -0,0 +1,88 @@
+// 2d_full.cpp
+// Copyright (C) Jacob Voytko 2007
+// Distributed under the Boost Software License, Version 1.0.
+// For more information, see http://www.boost.org
+// -----------------------------------------------------------------
+
+#include <boost/svg_plot/svg_2d_plot.hpp>
+#include <map>
+#include <cmath>
+
+using std::map;
+using namespace boost::svg;
+
+double f(double x)
+{
+ return sqrt(x);
+}
+
+double g(double x)
+{
+ return -2 + x*x;
+}
+
+double h(double x)
+{
+ return -1 + 2*x;
+}
+
+int main()
+{
+ map<double, double> data1, data2, data3;
+
+ for(double i=0; i<=10.; i+=1.)
+ {
+ data1[i] = f(i);
+ data2[i] = g(i);
+ data3[i] = h(i);
+ }
+
+ svg_2d_plot my_plot;
+
+ // Size/scale settings.
+ my_plot.image_size(700, 500)
+ .x_range(-1, 10)
+ .y_range(-5, 100);
+
+ // Text settings.
+ my_plot.title("Plot of Mathematical Functions")
+ .title_font_size(29)
+ .x_label("X Axis Units");
+
+ // Commands.
+ my_plot.legend_on(true)
+ .plot_window_on(true)
+ .x_label_on(true)
+ .x_major_labels_on(true);
+
+ // Color settings.
+ my_plot.background_color(svg_color(67, 111, 69))
+ .legend_background_color(svg_color(207, 202,167))
+ .legend_border_color(svg_color(102, 102, 84))
+ .plot_background_color(svg_color(136, 188, 126))
+ .title_color(white);
+
+ //X axis settings.
+ my_plot.x_major_tick(2)
+ .x_major_tick_length(14)
+ .x_major_tick_width(1)
+ .x_minor_tick_length(7)
+ .x_minor_tick_width(1)
+ .x_num_minor_ticks(3)
+
+ //Y axis settings.
+ .y_major_interval(10)
+ .y_num_minor_ticks(3);
+
+ //legend settings
+ my_plot.legend_title_font_size(15);
+
+ my_plot.plot(data1, "Sqrt(x)", red);
+ my_plot.plot(data2, "-2 + x^2", orange);
+ my_plot.plot(data3, "-1 + 2x", yellow,
+ _point_style = square, _size = 5);
+
+ my_plot.write("D:\\2d_full.svg");
+
+ return 0;
+}

Added: sandbox/SOC/2007/visualization/libs/svg_plot/example/2d_simple.cpp
==============================================================================
--- (empty file)
+++ sandbox/SOC/2007/visualization/libs/svg_plot/example/2d_simple.cpp 2007-07-28 20:42:53 EDT (Sat, 28 Jul 2007)
@@ -0,0 +1,38 @@
+// 2d_simple.cpp
+// Copyright (C) Jacob Voytko 2007
+// Distributed under the Boost Software License, Version 1.0.
+// For more information, see http://www.boost.org
+// -----------------------------------------------------------------
+
+#include <boost/svg_plot/svg_2d_plot.hpp>
+#include <vector>
+
+using std::map;
+using namespace boost::svg;
+
+int main()
+{
+ map<double, double> map1;
+ map<double, double> map2;
+
+ // This is random data used purely for example purposes.
+ map1[1.] = 3.2;
+ map1[2.] = 5.4;
+ map1[7.3] = 9.1;
+
+ map2[3.1] = 6.1;
+ map2[5.4] = 7.;
+
+ svg_2d_plot my_plot;
+
+ my_plot.title("Race Times")
+ .legend_on(true)
+ .x_range(-1, 11)
+ .background_border_color(black);
+
+ my_plot.plot(map1, "Series 1", blue);
+ my_plot.plot(map2, "Series 2", orange);
+
+ my_plot.write("D:\\simple_2d.svg");
+ return 0;
+}

Added: sandbox/SOC/2007/visualization/libs/svg_plot/example/2d_y_grid.cpp
==============================================================================
--- (empty file)
+++ sandbox/SOC/2007/visualization/libs/svg_plot/example/2d_y_grid.cpp 2007-07-28 20:42:53 EDT (Sat, 28 Jul 2007)
@@ -0,0 +1,46 @@
+// 2d_y_grid.cpp
+// Copyright (C) Jacob Voytko 2007
+// Distributed under the Boost Software License, Version 1.0.
+// For more information, see http://www.boost.org
+// -----------------------------------------------------------------
+
+#include <boost/svg_plot/svg_2d_plot.hpp>
+#include <vector>
+
+using std::map;
+using namespace boost::svg;
+
+int main()
+{
+ map<double, double> map1;
+ map<double, double> map2;
+
+ // This is random data used purely for example purposes.
+ map1[1.] = 3.2;
+ map1[2.] = 5.4;
+ map1[7.3] = 9.1;
+
+ map2[3.1] = 6.1;
+ map2[5.4] = 7.;
+
+ svg_2d_plot my_plot;
+
+ my_plot.title("Race Times")
+ .legend_on(true)
+ .x_range(-1, 11)
+ .background_border_color(black)
+ .plot_window_on(true);
+
+ my_plot.y_major_grid_on(true)
+ .y_minor_grid_on(true);
+
+ my_plot.y_major_grid_color(black)
+ .y_minor_grid_color(lightgray);
+
+
+ my_plot.plot(map1, "Series 1", blue);
+ my_plot.plot(map2, "Series 2", orange);
+
+ my_plot.write("D:\\2d_y_grid.svg");
+ return 0;
+}


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