|
Boost-Commit : |
Subject: [Boost-commit] svn:boost r52013 - sandbox/SOC/2007/visualization/libs/svg_plot/example
From: pbristow_at_[hidden]
Date: 2009-03-27 09:00:28
Author: pbristow
Date: 2009-03-27 09:00:26 EDT (Fri, 27 Mar 2009)
New Revision: 52013
URL: http://svn.boost.org/trac/boost/changeset/52013
Log:
Yet more doc correctins and updates.
Added:
sandbox/SOC/2007/visualization/libs/svg_plot/example/1d_full_layout.svg (contents, props changed)
sandbox/SOC/2007/visualization/libs/svg_plot/example/Jamfile.v2 (contents, props changed)
sandbox/SOC/2007/visualization/libs/svg_plot/example/demo_1d_heat_flow_data.cpp (contents, props changed)
sandbox/SOC/2007/visualization/libs/svg_plot/example/demo_1d_uncertainty.cpp (contents, props changed)
sandbox/SOC/2007/visualization/libs/svg_plot/example/demo_2d_autoscaling.cpp (contents, props changed)
sandbox/SOC/2007/visualization/libs/svg_plot/example/demo_2d_lines.cpp (contents, props changed)
sandbox/SOC/2007/visualization/libs/svg_plot/example/demo_2d_uncertainty.cpp (contents, props changed)
sandbox/SOC/2007/visualization/libs/svg_plot/example/demo_FP_compare.cpp (contents, props changed)
Text files modified:
sandbox/SOC/2007/visualization/libs/svg_plot/example/demo_1d_x_external.cpp | 2
sandbox/SOC/2007/visualization/libs/svg_plot/example/demo_2d_histogram.cpp | 9 +--
sandbox/SOC/2007/visualization/libs/svg_plot/example/demo_2d_plot.cpp | 8 +--
sandbox/SOC/2007/visualization/libs/svg_plot/example/demo_annotation.cpp | 5 +
sandbox/SOC/2007/visualization/libs/svg_plot/example/svg_test.cpp | 91 +++++++++++++++++++++++++++++----------
5 files changed, 77 insertions(+), 38 deletions(-)
Added: sandbox/SOC/2007/visualization/libs/svg_plot/example/1d_full_layout.svg
==============================================================================
Binary file. No diff available.
Added: sandbox/SOC/2007/visualization/libs/svg_plot/example/Jamfile.v2
==============================================================================
--- (empty file)
+++ sandbox/SOC/2007/visualization/libs/svg_plot/example/Jamfile.v2 2009-03-27 09:00:26 EDT (Fri, 27 Mar 2009)
@@ -0,0 +1,100 @@
+# I:\boost-sandbox\SOC\2007\visualization\libs\svg_plot\example\Jamfile.v2
+
+# Runs SVG Plot examples
+
+# Copyright 2009 Paul A. Bristow.
+
+# Distributed under the Boost Software License, Version 1.0.
+# (See accompanying file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
+
+# bring in the rules for testing
+import testing ;
+
+project
+ : requirements
+ <toolset>gcc:<cxxflags>-Wno-missing-braces
+ <toolset>darwin:<cxxflags>-Wno-missing-braces
+ <toolset>acc:<cxxflags>+W2068,2461,2236,4070
+ <toolset>intel:<cxxflags>-Qwd264,239
+ <toolset>msvc:<warnings>all
+ <toolset>msvc:<asynch-exceptions>on
+ <toolset>msvc:<cxxflags>/wd4800 # forcing value to bool 'true' or 'false'
+ <toolset>msvc:<cxxflags>/wd4996 # Deprecated.
+ <toolset>msvc:<cxxflags>/wd4512 # assignment operator could not be generated.
+ <toolset>msvc:<cxxflags>/wd4610
+ <toolset>msvc:<cxxflags>/wd4510
+ <toolset>msvc:<cxxflags>/wd4127
+ <toolset>msvc:<cxxflags>/wd4701
+ <toolset>msvc:<cxxflags>/wd4127 # expression is constant.
+ <toolset>msvc:<cxxflags>/wd4305
+ <toolset>msvc:<cxxflags>/wd4503 # decorated name length exceeded, name was truncated.
+ <toolset>msvc:<cxxflags>/wd4180 # qualifier applied to function type has no meaning; ignored.
+ <include>../../..
+ <include>$(boost_root)
+ ;
+
+run 1d_full_layout.cpp ;
+run 1d_simple_style.cpp ;
+run 1d_x_external.cpp ;
+run 1d_x_grid.cpp ;
+run 2d_area_fill.cpp ;
+run 2d_bezier.cpp ;
+run 2d_full.cpp ;
+run 2d_limit.cpp ;
+run 2d_simple.cpp ;
+run 2d_y_grid.cpp ;
+run auto_1d_containers.cpp ;
+run auto_1d_plot.cpp ;
+run auto_2d_plot.cpp ;
+run auto_boxplot.cpp ;
+run boxplot_full.cpp ;
+run boxplot_simple.cpp ;
+run container_minmax.cpp ;
+run demo_1d_autoscaling.cpp ;
+run demo_1d_axis_scaling.cpp ;
+run demo_1d_containers.cpp ;
+run demo_1d_limits.cpp ; #
+run demo_1d_plot.cpp ; # Demonstration of many features for 1D plots.
+run demo_1d_simple.cpp ;
+run demo_1d_uncertainty.cpp ; # Demonstrate showing uncertainty as 1 sd, 2 sd, 3 sd ellipses.
+run demo_1d_values.cpp ; # Demonstration of some simple 1D value formatting.
+run demo_1d_vector.cpp ; # Simple plot of vector of 1D data.
+run demo_1d_x_external.cpp ; #
+run demo_1d_heat_flow_data.cpp ; # demonstrate 1d and boxplot of NIST heatflow data.
+run demo_2d_autoscaling.cpp ;
+run demo_2d_bars.cpp ; # Demonstrate the bars (& columns or sticks).
+run demo_2d_histogram.cpp ; # Demonstrate drawing histogram.
+run demo_2d_limits.cpp ; #
+run demo_2d_lines.cpp ; # Demonstrate fit lines.
+run demo_2d_plot.cpp ; # Demonstration of some 2D plot features.
+run demo_2d_simple.cpp ; # Demonstration of some simple 2D plot features.
+run demo_2d_uncertainty.cpp ; # Demonstrate showing uncertainty as 1 sd, 2 sd, 3 sd ellipses.
+run demo_2d_values.cpp ; # Demonstration of marking values in 2D plots.
+run demo_annotation.cpp ; # Demonstration of adding textual annotation.
+run demo_boxplot.cpp ; # Demonstration of boxplots.
+run demo_boxplot_full.cpp ; # Demonstration of more options for Boxplots.
+run demo_boxplot_simple.cpp ; # Demonstration of simple boxplot.
+run demo_color.cpp ; # Demonstration of some SVG color features.
+run demo_Hoaglin.cpp ; # Demonstration of Boxplot quartile options.
+run demo_point_markers.cpp ; # Demonstration of marking data point options.
+run demo_rounds.cpp ; # Demonstration of rounding algorithm used for binary, five, decimal autoscaling.
+run demo_svg.cpp ;
+run demo_svg_tspan.cpp ; # Demonstration of tspan commands.
+run svg_colors.cpp ;
+run svg_test.cpp ;
+run svg_test_boxplot.cpp ;
+run demo_fp_compare.cpp ; #
+
+#run test_1d_color_consistency.cpp ;
+#run test_legend_place.cpp ;
+#run test_quantiles.cpp ;
+#run test_axis_labels.cpp ;
+#run test_axis_scaling.cpp ;
+#run test_axis_scaling2.cpp ;
+#run test_sci.cpp ;
+#run test_unc.cpp ;
+#run test_unc_pair.cpp ;
+
+#run default_1d_plot.cpp ;
+#run default_2d_plot.cpp ;
+#run test_axis_scaling.cpp ;
Added: sandbox/SOC/2007/visualization/libs/svg_plot/example/demo_1d_heat_flow_data.cpp
==============================================================================
--- (empty file)
+++ sandbox/SOC/2007/visualization/libs/svg_plot/example/demo_1d_heat_flow_data.cpp 2009-03-27 09:00:26 EDT (Fri, 27 Mar 2009)
@@ -0,0 +1,318 @@
+/*! \file demo_1d_heat_flow_data.cpp
+ \brief Demonstration of 1D plotting with some real-life data.
+ \details
+ An example to show Heat Flow data from
+ http://www.itl.nist.gov/div898/handbook/eda/section4/eda4281.htm
+ This data set was collected by Bob Zarr of NIST in January, 1990
+ from a heat flow meter calibration and stability analysis.
+
+ This data was used in an example in the Boost.Math Library.
+
+ \author Paul A Bristow
+ \date Mar 2009
+
+*/
+
+// Copyright Paul A Bristow 2008
+
+// Use, modification and distribution are subject to the
+// Boost Software License, Version 1.0.
+// (See accompanying file LICENSE_1_0.txt
+// or copy at http://www.boost.org/LICENSE_1_0.txt)
+
+// This file is written to be included from a Quickbook .qbk document.
+// It can be compiled by the C++ compiler, and run. Any output can
+// also be added here as comment or included or pasted in elsewhere.
+// Caution: this file contains Quickbook markup as well as code
+// and comments: don't change any of the special comment markups!
+
+//[heat_flow_1d_plot_1
+// An example to show Heat Flow data from
+// http://www.itl.nist.gov/div898/handbook/eda/section4/eda4281.htm
+// This data set was collected by Bob Zarr of NIST in January, 1990
+// from a heat flow meter calibration and stability analysis.
+
+//#ifdef _MSC_VER
+// Path submitted to cure this.
+//# pragma warning (disable: 4510) // boost::array<T,N>' : default constructor could not be generated
+//# pragma warning (disable: 4610) // warning C4610: class 'boost::array<T,N>' can never be instantiated - user defined constructor required
+//#endif
+
+#include <boost/svg_plot/svg_1d_plot.hpp>
+ using namespace boost::svg;
+ using boost::svg::svg_1d_plot;
+#include <boost/svg_plot/svg_boxplot.hpp>
+ using boost::svg::svg_boxplot;
+
+#include <boost/svg_plot/show_1d_settings.hpp>
+ void boost::svg::show_1d_plot_settings(svg_1d_plot&);
+
+#include <iostream> // for debugging.
+ using std::cout;
+ using std::endl;
+
+#include <vector>
+ using std::vector;
+
+#include <limits>
+ using std::numeric_limits;
+
+int main()
+{
+ boost::array<const double, 195> heat_flows = {
+ 9.206343,
+ 9.299992,
+ 9.277895,
+ 9.305795,
+ 9.275351,
+ 9.288729,
+ 9.287239,
+ 9.260973,
+ 9.303111,
+ 9.275674,
+ 9.272561,
+ 9.288454,
+ 9.255672,
+ 9.252141,
+ 9.297670,
+ 9.266534,
+ 9.256689,
+ 9.277542,
+ 9.248205,
+ 9.252107,
+ 9.276345,
+ 9.278694,
+ 9.267144,
+ 9.246132,
+ 9.238479,
+ 9.269058,
+ 9.248239,
+ 9.257439,
+ 9.268481,
+ 9.288454,
+ 9.258452,
+ 9.286130,
+ 9.251479,
+ 9.257405,
+ 9.268343,
+ 9.291302,
+ 9.219460,
+ 9.270386,
+ 9.218808,
+ 9.241185,
+ 9.269989,
+ 9.226585,
+ 9.258556,
+ 9.286184,
+ 9.320067,
+ 9.327973,
+ 9.262963,
+ 9.248181,
+ 9.238644,
+ 9.225073,
+ 9.220878,
+ 9.271318,
+ 9.252072,
+ 9.281186,
+ 9.270624,
+ 9.294771,
+ 9.301821,
+ 9.278849,
+ 9.236680,
+ 9.233988,
+ 9.244687,
+ 9.221601,
+ 9.207325,
+ 9.258776,
+ 9.275708,
+ 9.268955,
+ 9.257269,
+ 9.264979,
+ 9.295500,
+ 9.292883,
+ 9.264188,
+ 9.280731,
+ 9.267336,
+ 9.300566,
+ 9.253089,
+ 9.261376,
+ 9.238409,
+ 9.225073,
+ 9.235526,
+ 9.239510,
+ 9.264487,
+ 9.244242,
+ 9.277542,
+ 9.310506,
+ 9.261594,
+ 9.259791,
+ 9.253089,
+ 9.245735,
+ 9.284058,
+ 9.251122,
+ 9.275385,
+ 9.254619,
+ 9.279526,
+ 9.275065,
+ 9.261952,
+ 9.275351,
+ 9.252433,
+ 9.230263,
+ 9.255150,
+ 9.268780,
+ 9.290389,
+ 9.274161,
+ 9.255707,
+ 9.261663,
+ 9.250455,
+ 9.261952,
+ 9.264041,
+ 9.264509,
+ 9.242114,
+ 9.239674,
+ 9.221553,
+ 9.241935,
+ 9.215265,
+ 9.285930,
+ 9.271559,
+ 9.266046,
+ 9.285299,
+ 9.268989,
+ 9.267987,
+ 9.246166,
+ 9.231304,
+ 9.240768,
+ 9.260506,
+ 9.274355,
+ 9.292376,
+ 9.271170,
+ 9.267018,
+ 9.308838,
+ 9.264153,
+ 9.278822,
+ 9.255244,
+ 9.229221,
+ 9.253158,
+ 9.256292,
+ 9.262602,
+ 9.219793,
+ 9.258452,
+ 9.267987,
+ 9.267987,
+ 9.248903,
+ 9.235153,
+ 9.242933,
+ 9.253453,
+ 9.262671,
+ 9.242536,
+ 9.260803,
+ 9.259825,
+ 9.253123,
+ 9.240803,
+ 9.238712,
+ 9.263676,
+ 9.243002,
+ 9.246826,
+ 9.252107,
+ 9.261663,
+ 9.247311,
+ 9.306055,
+ 9.237646,
+ 9.248937,
+ 9.256689,
+ 9.265777,
+ 9.299047,
+ 9.244814,
+ 9.287205,
+ 9.300566,
+ 9.256621,
+ 9.271318,
+ 9.275154,
+ 9.281834,
+ 9.253158,
+ 9.269024,
+ 9.282077,
+ 9.277507,
+ 9.284910,
+ 9.239840,
+ 9.268344,
+ 9.247778,
+ 9.225039,
+ 9.230750,
+ 9.270024,
+ 9.265095,
+ 9.284308,
+ 9.280697,
+ 9.263032,
+ 9.291851,
+ 9.252072,
+ 9.244031,
+ 9.283269,
+ 9.196848,
+ 9.231372,
+ 9.232963,
+ 9.234956,
+ 9.216746,
+ 9.274107,
+ 9.273776
+};
+
+ try
+ { /*`try'n'catch block Very useful to ensure you see any error messages! */
+
+ vector<double> heat_flow_data(heat_flows.begin(), heat_flows.end()); // Copy from Boost.array to vector.
+ // This might be useful if data is in a C array.
+
+ svg_1d_plot heat_flow_1d_plot; // Construct with all the default constructor values.
+ heat_flow_1d_plot.document_title("NIST Heat_Flow Data") // This text shows on the browser tab.
+ .description("NIST Heat_Flow Data")
+ .copyright_date("2008-06-19")
+ .copyright_holder("Paul A. Bristow, Bob Zarr, NIST")
+ .license("permits", "permits", "requires", "permits", "permits"); // Require notice only.
+ //see http://creativecommons.org/licenses/ for details.
+ // This will generate an XML comment and an author and rights entries thus:
+ // <!-- SVG Plot Copyright Paul A. Bristow, Bob Zarr, NIST 2008-06-19 -->
+ // <dc:author><cc:Agent><dc:title>Paul A. Bristow, Bob Zarr, NIST </dc:title> </cc:Agent> </dc:author>
+ // <dc:rights><cc:Agent><dc:title>Paul A. Bristow, Bob Zarr, NIST</dc:title></cc:Agent></dc:rights>
+
+ heat_flow_1d_plot.coord_precision(6); // Some rather precise data real-life,
+ // so use high precision (even at the expense of slightly longer svg files).
+
+ heat_flow_1d_plot
+ .title("NIST Heat flow data") // Add title for the plot.
+ .x_label("heat flow") // Add a label for the X-axis.
+ .x_autoscale(heat_flow_data); // Use autoscale from this data.
+
+ heat_flow_1d_plot.plot(heat_flows, "NIST heat flows"); // Add a dataset as an array.
+ //heat_flow_1d_plot.plot(heat_flow_data, "NIST heat flows"); // Add a dataset.
+ heat_flow_1d_plot.write("./heat_flow_data.svg");
+
+ /*`Now we use a boxplot to show the same data, including its quartiles and any outliers. */
+
+ svg_boxplot heat_flow_boxplot; // Construct with all the default constructor values.
+ heat_flow_boxplot.y_autoscale(heat_flow_data); // Autoscale using this heat_flow data.
+ heat_flow_boxplot.title("NIST Heat_Flow Data"); // Give a title.
+ heat_flow_boxplot.plot(heat_flow_data, "NIST heat flows"); // Add a dataset.
+ heat_flow_boxplot.write("./heat_flow_data_boxplot.svg");
+ }
+ catch(const std::exception& e)
+ {
+ std::cout <<
+ "\n""Message from thrown exception was:\n " << e.what() << std::endl;
+ }
+//] [/heat_flow_1d_plot_1]
+
+ return 0;
+} // int main()
+
+/*
+
+Compiling...
+demo_1d_heat_flow_data.cpp
+Linking...
+Embedding manifest...
+Autorun "j:\Cpp\SVG\Debug\demo_heatflow_examples.exe
+
+
+*/
+
Added: sandbox/SOC/2007/visualization/libs/svg_plot/example/demo_1d_uncertainty.cpp
==============================================================================
--- (empty file)
+++ sandbox/SOC/2007/visualization/libs/svg_plot/example/demo_1d_uncertainty.cpp 2009-03-27 09:00:26 EDT (Fri, 27 Mar 2009)
@@ -0,0 +1,158 @@
+/*! \file demo_1d_uncertainty.cpp
+ \brief Simple plot of uncertainty of 1D data.
+ \details An example to demonstrate simple 1D plot using two vectors,
+ including showing values with uncertainty information as 'plus minus' and degrees of freedom estimates.
+ \author Paul A. Bristow
+ \date Mar 2009
+*/
+
+// Copyright Paul A Bristow 2009
+
+// Use, modification and distribution are subject to the
+// Boost Software License, Version 1.0.
+// (See accompanying file LICENSE_1_0.txt
+// or copy at http://www.boost.org/LICENSE_1_0.txt)
+
+// This file is written to be included from a Quickbook .qbk document.
+// It can be compiled by the C++ compiler, and run. Any output can
+// also be added here as comment or included or pasted in elsewhere.
+// Caution: this file contains Quickbook markup as well as code
+// and comments: don't change any of the special comment markups!
+
+//[demo_1d_uncertainty_1
+
+/*`First we need a few includes to use Boost.Plot:
+*/
+#include <boost/svg_plot/uncertain.hpp>
+ // using boost::svg::unc; // Holds value and uncertainty formation.
+#include <boost/svg_plot/detail/functors.hpp>
+// using boost::svg::detail::unc_1d_convert;
+#include <boost/svg_plot/svg_1d_plot.hpp>
+ using namespace boost::svg;
+
+#include <iostream>
+ using std::cout;
+ using std::endl;
+#include <vector>
+ using std::vector;
+#include <iterator>
+ using std::ostream_iterator;
+#include <algorithm>
+ using std::copy;
+
+//] [/demo_1d_uncertainty_1]
+
+int main()
+{
+//[demo_1d_uncertainty_2
+
+/*`STL vector is used as the container for our two data series,
+and values are inserted using push_back. Since this is a 1-D plot
+the order of data values is not important.
+*/
+ vector<unc> A_times;
+ A_times.push_back(unc(3.1, 0.02F, 8));
+ A_times.push_back(unc(4.2, 0.01F, 14));
+
+ vector<unc> B_times;
+ B_times.push_back(unc(2.1, 0.001F, 30, 0xFF)); // Value, uncertainty, degrees of freedom and type known.
+ // (But use of type is not yet implemented.)
+ B_times.push_back(unc(5.1, 0.025F, 20)); // Value, uncertainty, and degrees of freedom known - the usual case.
+ B_times.push_back(unc(7.8, 0.0025F)); // Value and uncertainty known, but not degrees of freedom.
+ B_times.push_back(unc(3.4, 0.03F)); // Value and uncertainty known, but not degrees of freedom.
+ B_times.push_back(unc(6.9)); // Only value known - no information available about uncertainty.
+
+ vector<unc> C_times;
+ C_times.push_back(unc(0.6, 0.1F, 5));
+ C_times.push_back(unc(1.4, 0.2F, 11));
+
+ /*`Echo the values input: */
+ copy(A_times.begin(), A_times.end(), ostream_iterator<unc>(std::cout, " "));
+ cout << endl;
+ copy(B_times.begin(), B_times.end(), ostream_iterator<unc>(std::cout, " "));
+ cout << endl;
+ /*`The constructor initializes a new 1D plot, called `my_plot`, and also sets all the very many defaults for axes, width, colors, etc.
+*/
+ svg_1d_plot my_plot;
+/*`A few (member) functions that set are fairly self-explanatory:
+
+* title provides a title at the top for the whole plot,
+* `legend_on(true)` will mean that titles of data series and markers will display in the legend box.
+* `x_range(-1, 11)` sets the axis limits from -1 to +11 (instead of the default -10 to +10).
+* `background_border_color(blue)` sets just one of the very many options.
+*/
+ my_plot.autoscale_check_limits(false); // default is true.
+ my_plot.autoscale_plusminus(3); // default is 3.
+
+
+ my_plot
+ .plot_window_on(true)
+ .background_border_color(blue)
+ .plot_border_color(yellow)
+ .plot_border_width(1)
+ //.x_ticks_on_window_or_axis(0) // now the default
+ .legend_on(false)
+ .title("Times")
+ .x_range(0, 10)
+ .x_label("times (sec)")
+ .x_values_on(true)
+ .x_values_precision(2)
+ .x_values_rotation(slopeup)
+ .x_plusminus_color(blue)
+ .x_plusminus_on(true)
+ .x_df_on(true)
+ .x_df_color(green)
+ .x_autoscale(A_times)
+ ;
+/*`
+Then we add our data series,
+and add optional data series titles
+(very helpful if we want them to show on the legend).
+
+The A_times mark data points with a red border circle with a green fill,
+The B_times use a blue vertical line,
+while C_times use an ellipse whose width (x radius) is from the uncertainty.
+All the data points are also labelled with their value,
+and uncertainty and degrees of freedom if known.
+
+*/
+
+ my_plot.plot(A_times, "A").shape(round).size(10).stroke_color(red).fill_color(green);
+ my_plot.plot(B_times, "B").shape(vertical_line).stroke_color(blue);
+ my_plot.plot(C_times, "C").shape(unc_ellipse).fill_color(lightyellow).stroke_color(magenta);
+
+/*`Finally, we can write the SVG to a file of our choice.
+*/
+ my_plot.write("./demo_1d_uncertainty.svg");
+//] [/demo_1d_uncertainty_2]
+
+ return 0;
+} // int main()
+
+/*
+
+Output:
+//[demo_1d_uncertainty_output
+demo_1d_uncertainty.cpp
+Linking...
+Embedding manifest...
+Autorun j:\Cpp\SVG\debug\demo_1d_uncertainty.exe
+3.1±0.02 (8) 4.2±0.01 (14)
+2.1±0.001 (30) 7.8±0.0025 (21) 3.4±0.03 6.9
+Build Time 0:03
+//] [/demo_1d_uncertainty_output]
+*/
+
+/*
+Data for another 1D example, also use Boost.Math?
+
+The data is taken from J. C. Banford el al, Analyst (1983) 107, 195
+and compares the concentration of thiol of the lysate of the blood of two groups
+of volunteers as control and a second suffering from rhematoid arthritis.
+
+ map<pair<unc, unc> > control;
+ control.push_back(unc(1.921, 0.076F, 7));
+ map<pair<unc, unc> > rheumatoid;
+ control.push_back(unc(3.456, 0.44F, 6));
+
+ */
Modified: sandbox/SOC/2007/visualization/libs/svg_plot/example/demo_1d_x_external.cpp
==============================================================================
--- sandbox/SOC/2007/visualization/libs/svg_plot/example/demo_1d_x_external.cpp (original)
+++ sandbox/SOC/2007/visualization/libs/svg_plot/example/demo_1d_x_external.cpp 2009-03-27 09:00:26 EDT (Fri, 27 Mar 2009)
@@ -61,7 +61,7 @@
enum x_axis_intersect
{ //! \enum x_axis_intersect
bottom = -1, // On the bottom of the plot window.
- x_intersects_y = 0, // On the X axis (in the middle of the plot window).
+ x_intersects_y = 0, // On the Y axis (in the middle of the plot window).
top = +1 // On the top of the plot window.
};
``
Added: sandbox/SOC/2007/visualization/libs/svg_plot/example/demo_2d_autoscaling.cpp
==============================================================================
--- (empty file)
+++ sandbox/SOC/2007/visualization/libs/svg_plot/example/demo_2d_autoscaling.cpp 2009-03-27 09:00:26 EDT (Fri, 27 Mar 2009)
@@ -0,0 +1,104 @@
+/*! \file demo_2d_autoscaling.cpp
+ \brief Demonstration of autoscaling in 2D plots.
+ \details An example to demonstrate simplest 2d *default* settings.
+ See also auto_2d_plot.cpp for a wider range of use.
+
+ \date 20 Mar 2009
+ \author Paul A. Bristow
+*/
+// Copyright Paul A Bristow 2009
+
+// Use, modification and distribution are subject to the
+// Boost Software License, Version 1.0.
+// (See accompanying file LICENSE_1_0.txt
+// or copy at http://www.boost.org/LICENSE_1_0.txt)
+
+// This file is written to be included from a Quickbook .qbk document.
+// It can be compiled by the C++ compiler, and run. Any output can
+// also be added here as comment or included or pasted in elsewhere.
+// Caution: this file contains Quickbook markup as well as code
+// and comments: don't change any of the special comment markups!
+
+//[demo_2d_autoscaling_1
+
+/*`As always, we need a few includes to use Boost.Plot
+*/
+
+#include <boost/svg_plot/svg_2d_plot.hpp>
+ using namespace boost::svg;
+ using boost::svg::svg_2d_plot;
+
+#include <iostream>
+ using std::cout;
+ using std::endl;
+ using std::dec;
+ using std::hex;
+
+#include <map>
+ using std::map;
+
+//] [demo_2d_autoscaling_1]
+
+int main()
+{
+
+//[demo_2d_autoscaling_2
+/*`Some fictional data is pushed into an STL container, here map:\n
+
+ This example uses a single map to demonstrate autoscaling.
+ We construct a map to hold our data series, and insert some fictional values (that also sorts the data).
+ The index value in [] is the x value.
+ */
+ map<const double, double> my_data;
+ my_data[1.1] = 3.2;
+ my_data[7.3] = 9.1;
+ my_data[2.12] = 2.4394;
+ my_data[5.47] = 5.3861;
+
+ try
+ { // try'n'catch clocks are needed to ensure error messages from any exceptions are shown.
+ svg_2d_plot my_2d_plot; // Construct a plot with all the default constructor values.
+ my_2d_plot.title("Autoscaling 2d Values"); // Add a string title of the plot.
+
+/*` With the defaults ranges would be -10 to +10 for both X and Y axes. We could chose our own ranges
+ `.x_range(0, 6) // Add a range for the X-axis.`
+ `.y_range(0, 10) // Add a range for the Y-axis.`
+ Or we can use autoscaling.
+
+*/
+ my_2d_plot.xy_autoscale(my_data); // Autoscale both x and Y axes.
+
+ /*`This says use the entire STL container my_data to set both X and Y ranges.
+(The data used to autoscale the range(s) does not have to be the same as the data being plotted.
+For example, if we have analysed a product and know that an attribute like strength can only decline as the product ages,
+it would make sense to use the reference 'as new' data to scale the plot for the 'aged' product samples).
+
+The add the (one but could be more) data series, `my_data` and a description, and how the data points are to be marked,
+here a circle with a diameter of 5 pixels, without a line joining the points.
+*/
+ my_2d_plot.plot(my_data, "2d Values").shape(round).size(6).line_on(false);
+
+/*`To use all these settings, finally write the plot to file.
+*/
+ my_2d_plot.write("./demo_2d_autoscaling.svg");
+
+//] [demo_2d_autoscaling_2]
+ }
+ catch(const std::exception& e)
+ {
+ std::cout <<
+ "\n""Message from thrown exception was:\n " << e.what() << std::endl;
+ }
+ return 0;
+} // int main()
+
+/*
+
+//[demo_2d_autoscaling_output
+
+Output:
+
+
+
+*/
+
Modified: sandbox/SOC/2007/visualization/libs/svg_plot/example/demo_2d_histogram.cpp
==============================================================================
--- sandbox/SOC/2007/visualization/libs/svg_plot/example/demo_2d_histogram.cpp (original)
+++ sandbox/SOC/2007/visualization/libs/svg_plot/example/demo_2d_histogram.cpp 2009-03-27 09:00:26 EDT (Fri, 27 Mar 2009)
@@ -65,7 +65,6 @@
time2s[90] = 10000.; // 5 57 90 to 150 min
time2s[150] = 0.; // Final bin end (15) with zero value.
-
// Check that the last element contains the expected last bin end.
std::map<double, double>::const_iterator last = times.end();
last--;
@@ -122,7 +121,6 @@
cout << b << endl;
b.write(cout);
-
// Plot the histogram.
svg_2d_plot my_plot1;
@@ -144,17 +142,16 @@
.y_num_minor_ticks(4) // plus 1 major = 5 ticks per major step.
;
- //my_plot1.plot(times, "Series 1").shape(none).line_on(false).histogram(column); // Need to supress line and shape plot options.
+ //my_plot1.plot(times, "Series 1").shape(none).line_on(false).area_fill(red).histogram(column); // Need to supress line and shape plot options.
// TODO change shape and line to off automatically when histogram is chosen?
//my_plot1.plot(times, "Journey time").shape(none).line_on(false).line_color(red).area_fill(pink). histogram(column);
- //my_plot1.plot(time2s, "2050 times? ").shape(none).line_on(false).line_color(blue).area_fill(lightblue).histogram(column);
+ my_plot1.plot(time2s, "2050 times? ").shape(none).line_on(false).line_color(blue).area_fill(lightblue).histogram(column);
// Overlay hides plot details underneath.
- //my_plot1.write("./demo_2d_histogram_x.svg");
+ my_plot1.write("./demo_2d_histogram_x.svg");
my_plot1.plot(time2s, "2050 times? ").shape(none).line_on(false).line_color(blue).area_fill(blank).histogram(column);
my_plot1.write("./demo_2d_histogram_x2.svg");
-
return 0;
} // int main()
Added: sandbox/SOC/2007/visualization/libs/svg_plot/example/demo_2d_lines.cpp
==============================================================================
--- (empty file)
+++ sandbox/SOC/2007/visualization/libs/svg_plot/example/demo_2d_lines.cpp 2009-03-27 09:00:26 EDT (Fri, 27 Mar 2009)
@@ -0,0 +1,123 @@
+/*! \file demo_2d_lines.cpp
+ \brief Demonstration of 2D 'function' lines, for example a least-squares fit line.
+ \details Adding lines and curves to a plot.
+ \author Paul A. Bristow
+ \date Mar 2009
+*/
+
+// Copyright Paul A. Bristow 2009
+
+// Use, modification and distribution are subject to the
+// Boost Software License, Version 1.0.
+// (See accompanying file LICENSE_1_0.txt
+// or copy at http://www.boost.org/LICENSE_1_0.txt)
+
+// This file is written to be included from a Quickbook .qbk document.
+// It can be compiled by the C++ compiler, and run. Any output can
+// also be added here as comment or included or pasted in elsewhere.
+// Caution: this file contains Quickbook markup as well as code
+// and comments: don't change any of the special comment markups!
+
+#ifdef _MSC_VER
+# pragma warning (disable : 4800) // forcing value to bool 'true' or 'false' (performance warning)
+# pragma warning (disable : 4180) // qualifier applied to function type has no meaning; ignored
+# pragma warning (disable : 4503) // decorated name length exceeded, name was truncated
+# pragma warning (disable : 4512) // assignment operator could not be generated
+# pragma warning (disable : 4100) // unreferenced formal parameter
+#endif
+
+//[demo_2d_lines_1
+
+/*`First we need some includes to use Boost.Plot and C++ Standard Library:
+*/#include <boost/svg_plot/svg_2d_plot.hpp>
+using namespace boost::svg;
+
+#include <boost/svg_plot/show_2d_settings.hpp>
+// using boost::svg::show_2d_plot_settings - Only needed for showing which settings in use.
+
+#include <map>
+ using std::map;
+ using std::multimap;
+
+#include <iostream>
+ using std::cout;
+ using std::endl;
+ using std::boolalpha;
+
+int main()
+{
+ try
+ {
+//[demo_2d_lines_2
+
+/*`
+This shows how to add lines to a plot, for example, for example a least-squares 'function' fit line.
+The data is roughly a straight line through the origin.
+*/
+
+ map<double, double> my_data;
+ my_data[-1.1] = -1.2;
+ my_data[-2.3] = -2.1;
+ my_data[-2.9] = -3.3;
+ my_data[-4.1] = -4.3;
+ my_data[-5.0] = -5.3;
+ my_data[-6.1] = -5.9;
+ my_data[0.] = 0.;
+ my_data[1.1] = 1.2;
+ my_data[2.3] = 2.1;
+ my_data[2.9] = 3.3;
+ my_data[4.1] = 4.3;
+ my_data[5.0] = 5.3;
+ my_data[6.1] = 5.9;
+
+ /*`
+ First construct, size and draw a simple plot ready to add some sample lines.
+ */
+ svg_2d_plot my_plot;
+ my_plot.size(400, 400);
+ my_plot.plot(my_data, "my_data").fill_color(red);
+
+ /*`
+ First draw a line using SVG coordinates (rather than the Cartesian coordinates used for user's data - see below).
+ Note that for SVG coordinates, Y increases *down* the page, so Y = 0 is the top and Y = 300 is the bottom.
+ Default black is provided for color.
+ */
+ my_plot.draw_line(10, 390, 390, 10);
+
+/*`This line almost reaches the corners of the SVG image, but for plotting XY graphs,
+you probably don't want SVG coordinates, but want to use Cartesian coordinates for user's data.
+Now draw a blue line using the Cartesian coordinates for user's data,
+from the bottom left through the origin of the plot to the top right of the plot.
+
+*/
+ my_plot.draw_plot_line(-10, -10, +10, +10, blue);
+
+/*`If you have calculated a confidence interval, you might want to add curved line(s) showing it (still using the Cartesian coordinates).
+For example, you can draw a curve (quadratic) through two X, Y pairs using a Bezier curve with the middle point as control point.
+*/
+ my_plot.draw_plot_curve(-6, -8, 0, +1, +8, +6, red);
+
+/*`Finally write the SVG image file.
+[note At present, notes and lines must come after all plot commands to be put in the correct place.]
+*/
+
+ my_plot.write("./demo_2d_lines");
+
+ //show_2d_plot_settings(my_plot);
+
+//] [/demo_2d_lines_2]
+
+ }
+ catch (const std::exception& e)
+ {
+ std::cout <<
+ "\n""Message from thrown exception was:\n " << e.what() << std::endl;
+ }
+ return 0;
+} // int main()
+
+/*
+
+Output :
+
+*/
Modified: sandbox/SOC/2007/visualization/libs/svg_plot/example/demo_2d_plot.cpp
==============================================================================
--- sandbox/SOC/2007/visualization/libs/svg_plot/example/demo_2d_plot.cpp (original)
+++ sandbox/SOC/2007/visualization/libs/svg_plot/example/demo_2d_plot.cpp 2009-03-27 09:00:26 EDT (Fri, 27 Mar 2009)
@@ -263,14 +263,12 @@
plot("Plot of Mathematical Functions", "./demo_2d_plot_XYP.svg", "X-axis", +1., +10., "Y-axis", +1., +10.); // x & y all > 0
plot("Plot of Mathematical Functions", "./demo_2d_plot_XYN.svg", "X-axis", -10., -1., "Y-axis", -10., -1.); // x & y all < 0
plot("Title with Unicode <sup>-α </sup> Ω Φ √ ∞ ζ ±", "./demo_2d_plot_XYPM.svg", "X-axis ±Ω", -10., +10., "Y-axis ∞√", -10., +10.); // Both X & Y include zero.
-
}
- catch (char* message)
+ catch (const std::exception& e)
{
- cout << message << endl;
+ std::cout <<
+ "\n""Message from thrown exception was:\n " << e.what() << std::endl;
}
-
-
return 0;
} // int main()
Added: sandbox/SOC/2007/visualization/libs/svg_plot/example/demo_2d_uncertainty.cpp
==============================================================================
--- (empty file)
+++ sandbox/SOC/2007/visualization/libs/svg_plot/example/demo_2d_uncertainty.cpp 2009-03-27 09:00:26 EDT (Fri, 27 Mar 2009)
@@ -0,0 +1,191 @@
+/*! \file demo_2d_uncertainty.cpp
+ \brief Demonstration of some 2D plot features.
+ \details including showing values with uncertainty information as 'plus minus' and degrees of freedom estimates.
+ \author Jacob Voytko and Paul A. Bristow
+ \date Mar 2009
+*/
+
+// Copyright Jacob Voytko 2007
+// Copyright Paul A. Bristow 2007, 2008, 2009
+
+// Use, modification and distribution are subject to the
+// Boost Software License, Version 1.0.
+// (See accompanying file LICENSE_1_0.txt
+// or copy at http://www.boost.org/LICENSE_1_0.txt)
+
+// This file is written to be included from a Quickbook .qbk document.
+// It can be compiled by the C++ compiler, and run. Any output can
+// also be added here as comment or included or pasted in elsewhere.
+// Caution: this file contains Quickbook markup as well as code
+// and comments: don't change any of the special comment markups!
+
+#ifdef _MSC_VER
+# pragma warning (disable : 4800) // forcing value to bool 'true' or 'false' (performance warning)
+# pragma warning (disable : 4180) // qualifier applied to function type has no meaning; ignored
+# pragma warning (disable : 4503) // decorated name length exceeded, name was truncated
+# pragma warning (disable : 4512) // assignment operator could not be generated
+# pragma warning (disable : 4100) // unreferenced formal parameter
+#endif
+
+//[demo_2d_uncertainty_1
+
+/*`First we need some includes to use Boost.Plot and C++ Standard Library:
+*/#include <boost/svg_plot/svg_2d_plot.hpp>
+using namespace boost::svg;
+
+#include <boost/svg_plot/show_2d_settings.hpp>
+// using boost::svg::show_2d_plot_settings - Only needed for showing which settings in use.
+#include <boost/svg_plot/uncertain.hpp>
+using boost::svg::unc;
+#include <boost/svg_plot/detail/pair.hpp>
+// using boost::svg::detail::pair; operator<<
+
+//#include <algorithm>
+//#include <functional>
+
+#include <map>
+ using std::map;
+ using std::multimap;
+
+#include <utility>
+ using std::pair;
+ using std::make_pair;
+
+#include <vector>
+ using std::vector;
+
+#include <cmath>
+ using std::sqrt;
+ using std::pair;
+#include <iostream>
+ using std::cout;
+ using std::endl;
+ using std::scientific;
+ using std::hex;
+ using std::ios;
+ using std::boolalpha;
+
+#include <iterator>
+ using std::ostream_iterator;
+
+//] [/demo_2d_uncertainty_1]
+
+ enum side
+ { //! \enum side Where axis labels go.
+ left_side = -1,
+ on_axis = 0,
+ right_side = +1,
+ bottom_side = -1,
+ top_side = +1,
+ };
+
+int main()
+{
+ try
+ {
+//[demo_2d_uncertainty_2
+
+/*`STL map is used as the container for our two data series,
+and pairs of values and their uncertainty information
+(approximately standard deviation and degrees of freedom)
+are inserted using push_back. Since this is a 2-D plot
+the order of data values is important.
+*/
+
+ unc u1(1.23, 0.56F, 7); // For an X value.
+ cout << "u1 = " << u1 << endl; // u1 = 1.23+-0.056 (7)
+ unc u2(3.45, 0.67F, 9); // For a Y value.
+ pair<unc, unc> mp1 = make_pair(u1, u2); // XY pair of values.
+ cout << mp1 << endl; // 1.23+-0.056 (7), 2.345+-0.067 (9)
+
+ map<unc, unc> data1; // Container for XY points.
+ data1.insert(mp1); // u1, u2 = 1.23+-0.056 (7), 2.345+-0.067 (9)
+ data1.insert(make_pair(unc(4.1, 0.4F, 7), unc(3.1, 0.3F, 18))); //
+ data1.insert(make_pair(unc(-2.234, 0.03F, 7), unc(-8.76, 0.9F, 9)));
+
+ /*`Make very sure you don't forget either unc() like this
+ `data1.insert(make_pair((-2.234, 0.12F, 7),(-8.76, 0.56F, 9)));`
+ because, by the bizarre operation of the comma operator, the result will be an integer!
+ So you will astonished to find that the values will be the pair of \b degrees of freedom, (7, 9)
+ and the other parts of unc will be undefined!/n
+
+ Echo the values input: */
+ cout << data1.size() << " XY data pairs:" << endl;
+ copy(data1.begin(), data1.end(), ostream_iterator<pair<unc, unc> >(cout, "\n"));
+ cout << endl;
+
+ svg_2d_plot my_plot;
+ /*`if you can be confident taht the data set only contains normal, valid data,
+ so none are 'at limits' too big or too small to be meaningful, infinite or NaN (NotANumber)
+ then these checks can be skipped (for speed).
+ An instrument or operator input might provide only normal data.
+ For this example, we know this is true, so override the default autoscale_check_limits(true).
+ */
+ //my_plot.autoscale_check_limits(false);
+ /*`The default is autoscale_plusminus(3.) so that confidence ellipses
+ at 1, 2 and 3 (uncertainty nominally standard deviations)
+ are all within the plot window,
+ but if you are less interested in seeing the 2 and 3 ellipses,
+ you could risk the outer edges spilling over the borders
+ by reducing autoscale_plusminus, for example, to 1.5, down to zero.*/
+ my_plot.autoscale_plusminus(1.5); // default is 3.
+
+ my_plot.autoscale(true);
+
+ /*`Use data set `data` to autoscale (you can use a different data set to scale from the one you chose to plot).
+ */
+ my_plot.xy_autoscale(data1);
+ my_plot
+ .x_label("times (sec)")
+ .xy_values_on(true)
+ // Note use of Unicode space in all string - ANSI space has no effect.
+ //.x_decor("", ", ") // Keep all on one line using spearator starting with a comma.
+ .x_decor("","") // Split onto two lines because X separator does not start with comma.
+ .y_decor("   ", "time = ", " sec")
+ // Note a few padding spaces used to get Y values to lie more nearly under X values.
+ // This is only necessary when label are not horizontal.
+ .x_values_rotation(slopeup)
+ .x_values_font_size(16)
+ .x_plusminus_on(true)
+ .x_plusminus_color(cyan)
+ .x_df_on(true)
+ .x_df_color(magenta)
+
+ .y_values_rotation(uphill)
+ .x_values_font_family("sans")
+ .y_plusminus_on(true)
+ .y_plusminus_color(red)
+ .y_df_on(true)
+ .y_df_color(green)
+ /*`The default uncertainty ellipse colors (that apply to both x and y axes)
+ can be changed thus:
+ */
+ .one_sd_color(lightblue)
+ .two_sd_color(svg_color(200, 230, 255))// rgb(176, 224, 230)
+ .three_sd_color(svg_color(230, 255, 255)) // rgb(240, 255, 255)
+ ;
+
+ my_plot.plot(data1, "data1").shape(unc_ellipse);
+
+ my_plot.write("./demo_2d_uncertainty");
+
+ //show_2d_plot_settings(my_plot);
+
+ //] [/demo_2d_uncertainty_2]
+
+ }
+ catch (const std::exception& e)
+ {
+ std::cout <<
+ "\n""Message from thrown exception was:\n " << e.what() << std::endl;
+ }
+ return 0;
+} // int main()
+
+/*
+
+Output :
+
+
+
+*/
Added: sandbox/SOC/2007/visualization/libs/svg_plot/example/demo_FP_compare.cpp
==============================================================================
--- (empty file)
+++ sandbox/SOC/2007/visualization/libs/svg_plot/example/demo_FP_compare.cpp 2009-03-27 09:00:26 EDT (Fri, 27 Mar 2009)
@@ -0,0 +1,196 @@
+/* \file demo_FP_compare.cpp
+ \brief demonstrate features of floating-point comparisons to find if values are close to each other,
+ or are too small to be significantly different from zero.
+
+ \author Paul A. Bristow
+ \date Mar 2009
+*/
+
+// Copyright Paul A. Bristow 2008, 2009
+
+// Distributed under the Boost Software License, Version 1.0.
+// (See accompanying file LICENSE_1_0.txt or copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+
+#include <iostream>
+ using std::cout;
+ using std::cin;
+ using std::endl;
+ using std::dec;
+ using std::hex;
+ using std::boolalpha;
+#include <iomanip>
+ using std::setprecision;
+ using std::setw;
+#include <string>
+ using std::string;
+#include <limits>
+ using std::numeric_limits;
+
+#include <boost/svg_plot/detail/FP_compare.hpp>
+
+int main()
+{
+ cout << "Demo FP compare";
+#if defined(__FILE__) && defined(__TIMESTAMP__)
+ cout << " " << __FILE__ << ' ' << __TIMESTAMP__ << ' '<< _MSC_FULL_VER;
+#endif
+ cout << boolalpha << endl;
+
+ {
+ // Check if a floating-point value is very close to zero, or exactly zero.
+ // Sort of operator ~= (if such a thing was possible)
+
+ // Use the default type double and the default small value 2 * min_value.
+ smallest<> t_def; // double is default FP type.
+ cout << t_def.size() << endl; // 4.45015e-308
+ cout << "t(0) " << t_def(0) << endl; // true - is *integer* zero.
+ cout << "t(0.) " << t_def(0.) << endl; // true = really is zero.
+
+ // Specify a default float value.
+ smallest<float> tf;
+ cout << "smallest<float> tf size = " << tf.size() << endl; // smallest<float> tf small = 2.35099e-038
+ cout << " tf(1e-38F) " << tf(1e-38F) << endl; // Smaller than float min_value, so expect true ~= zero.
+ cout << " tf(9.e-38F) " << tf(9.e-38F) << endl; // Larger than float min_value, so expect false != zero.
+
+ // Specify a chosen small float value of 1e-10.
+ smallest<float> tf10(1e-10F); // Note value must be a float - to match.
+ cout << "smallest<float> tf10(1e-10); = " << tf10.size() << endl; // smallest<float> tf10(1e-10); = 1e-010
+
+ cout << " tf10(1e-11F) " << tf10(1e-11F) << endl; // Smaller than float 1e-10, so expect true ~= zero.
+ cout << " tf10(tf10(9.e-9F) " << tf10(9.e-9F) << endl; // Larger than float 1e-10, so expect false != zero.
+
+ // Use convenience typdef for double and 2 * std::numeric_limits<double>::min()
+ // typedef smallest<double> tiny;
+
+ tiny tn;
+ cout << "tiny tn.size() = " << tn.size() << endl; // 4.45015e-308
+ cout<< "tn(0) " << tn(0) << endl; // true
+
+ smallest<double> z;
+ cout << z.size() << endl;
+ cout << z(1e-308) << endl;
+
+ tiny zz; // typedef smallest<double> tiny;
+ cout << zz.size() << endl;
+ cout << zz(1e-308) << endl;
+
+ double v = numeric_limits<double>::min();
+ if (zz(v))
+ {
+ cout << v << " is tiny." << endl;
+ }
+ tiny z0(0);
+ cout << zz.size() << endl;
+
+ tiny z00(0.);
+ cout << zz.size() << endl;
+
+
+ close_to<> is_near_100eps(std::numeric_limits<double>::epsilon(), FPC_WEAK);
+
+ cout << is_near_100eps(1., 1 + 90 * numeric_limits<double>::epsilon() ) << endl;
+ cout << is_near_100eps(1., 1 + 110 * numeric_limits<double>::epsilon() ) << endl;
+
+ }
+
+ { // Compare two floating-point values for being close enough to be considered 'equal'.
+// Demonstrate use of close-to to check close enough to meet tolerance.
+
+ // Use default tolerance
+ // This is twice numeric_limits min,
+ // which should allow for a few bits difference from computations.
+
+ // Specific type float, and both tolerance and strength specified.
+ close_to<float> t1(1e-15F, FPC_WEAK);
+ cout << "close_to() t1.size() " << t1.size() << ' ' << (t1.strength() == 0 ? "strong " : "weak" ) << endl; // 1e-015 weak
+ close_to<float> tdf; // default tolerance = 2 *epsilon and strength = strong
+ cout << "close_to<float> tdf.size() = " << tdf.size() << ' ' << (tdf.strength() == 0 ? "strong " : "weak" ) << endl; // 2.38419e-007 strong
+
+ // Use the default type double and the default tolerance value 2 * epsilon.
+ close_to<double> tds(1e-14, FPC_STRONG); // default strength = strong
+ cout << "close_to<double> tds.size() = " << tds.size() << ' ' << (tds.strength() == 0 ? "strong " : "weak" ) << endl;
+ close_to<double> tdw(1e-14, FPC_WEAK); // default strength = strong
+ cout << "close_to<double> tdw.size() = " << tdw.size() << ' ' << (tdw.strength() == 0 ? "strong " : "weak" ) << endl;
+ close_to<double> tdd; // default tolerance = 2 *epsilon and strength = strong
+ cout << "close_to<double> tdd.size() = " << tdd.size() << ' ' << (tdd.strength() == 0 ? "strong " : "weak" ) << endl;
+ close_to<double> tdds(1e-14); // specific tolerance but use default strength = strong
+ cout << "close_to<double> tdds.size() = " << tdds.size() << ' ' << (tdds.strength() == 0 ? "strong " : "weak" ) << endl;
+
+ close_to<> t; //
+ cout << "close_to<double> t.size() = " << t.size() << ' ' << (t.strength() == 0 ? "strong " : "weak" ) << endl;
+ cout << "close_to<double> tdd.size() = " << tdd.size() << ' ' << (tdd.strength() == 0 ? "strong " : "weak" ) << endl;
+
+ // neareq
+ // Use nearby the convenience typedef for close_to<double>
+ neareq neq;
+ cout << "neq(0) " << neq(0, FPC_STRONG) << endl; // true - is *integer* zero.
+ cout << "neq(0.) " << neq(0., FPC_STRONG) << endl; // true = really is zero.
+ cout << "neq(1 * numeric_limits<double>::min()) " << neq(1 * numeric_limits<double>::min(), 2 * numeric_limits<double>::min()) << endl; // true
+
+ neareq neqd(1 * numeric_limits<double>::min()); // Specify tolerance & rely on default strong requirement.
+ cout << neqd.size() << neqd.size() << ' ' << (neqd.strength() == 0 ? "strong " : "weak" ) << endl;
+ neareq neqdw(1 * numeric_limits<double>::min(), FPC_WEAK); // Both tolerance strength specified.
+ cout << neqdw.size() << neqdw.size() << ' ' << (neqdw.strength() == 0 ? "strong " : "weak" ) << endl;
+
+ cout << neq(1e-308, 1.1e-308) << endl;
+ cout << neq(1e-308, 1.0000000000000001e-308) << endl;
+
+ close_to<> is_near_100eps(100 * std::numeric_limits<double>::epsilon(), FPC_WEAK);
+ // Set a tolerance of 100 epsilon ~= 1e-14
+
+ cout << is_near_100eps(1., 1. + 90 * numeric_limits<double>::epsilon() ) << endl; // true
+ cout << is_near_100eps(1., 1. + 110 * numeric_limits<double>::epsilon() ) << endl; // false
+ }
+ return 0;
+} // int main()
+
+
+/*
+
+Output:
+
+Autorun "j:\Cpp\SVG\Debug\demo_fp_compare.exe
+Demo FP compare i:\boost-sandbox\SOC\2007\visualization\libs\svg_plot\example\demo_FP_compare.cpp Wed Mar 25 12:57:38 2009 150021022
+4.45015e-308
+t(0) true
+t(0.) true
+smallest<float> tf size = 2.35099e-038
+ tf(1e-38F) true
+ tf(9.e-38F) false
+smallest<float> tf10(1e-10); = 1e-010
+ tf10(1e-11F) true
+ tf10(tf10(9.e-9F) false
+tiny tn.size() = 4.45015e-308
+tn(0) true
+4.45015e-308
+true
+4.45015e-308
+true
+2.22507e-308 is tiny.
+4.45015e-308
+4.45015e-308
+false
+false
+close_to() t1.size() 1e-015 weak
+close_to<float> tdf.size() = 2.38419e-007 strong
+close_to<double> tds.size() = 1e-014 strong
+close_to<double> tdw.size() = 1e-014 weak
+close_to<double> tdd.size() = 4.44089e-016 strong
+close_to<double> tdds.size() = 1e-014 strong
+close_to<double> t.size() = 4.44089e-016 strong
+close_to<double> tdd.size() = 4.44089e-016 strong
+neq(0) true
+neq(0.) true
+neq(1 * numeric_limits<double>::min()) false
+2.22507e-3082.22507e-308 strong
+2.22507e-3082.22507e-308 weak
+false
+true
+true
+false
+
+*/
+
+
+
Modified: sandbox/SOC/2007/visualization/libs/svg_plot/example/demo_annotation.cpp
==============================================================================
--- sandbox/SOC/2007/visualization/libs/svg_plot/example/demo_annotation.cpp (original)
+++ sandbox/SOC/2007/visualization/libs/svg_plot/example/demo_annotation.cpp 2009-03-27 09:00:26 EDT (Fri, 27 Mar 2009)
@@ -108,9 +108,10 @@
//] [/demo_2d_annotation_2]
}
- catch (char* message)
+ catch (const std::exception& e)
{
- cout << message << endl;
+ std::cout <<
+ "\n""Message from thrown exception was:\n " << e.what() << std::endl;
}
return 0;
} // int main()
Modified: sandbox/SOC/2007/visualization/libs/svg_plot/example/svg_test.cpp
==============================================================================
--- sandbox/SOC/2007/visualization/libs/svg_plot/example/svg_test.cpp (original)
+++ sandbox/SOC/2007/visualization/libs/svg_plot/example/svg_test.cpp 2009-03-27 09:00:26 EDT (Fri, 27 Mar 2009)
@@ -1,16 +1,44 @@
-#include "svg_1d_plot.hpp"
-#include "svg_boxplot.hpp"
+/* \file svg_test.cpp
+ \brief demonstrate boxplot of common functions.
+ \details This shows the distribution of the function from the median, quartiles etc.
+ This is now obselete - see demo_boxplot.cpp.
+
+ \author Jake Voytko
+ \date Mar 2009
+*/
+
+// Copyright Jake Voytko 2007
+// Copyright Paul A. Bristow 2009
+
+// Distributed under the Boost Software License, Version 1.0.
+// (See accompanying file LICENSE_1_0.txt or copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+
+#ifdef _MSC_VER
+# pragma warning (disable : 4224) // warning C4224: nonstandard extension used : formal parameter 'function_ptr' was previously defined as a type
+// in boost/function/function_template.hpp. Should be fixed eventually.
+#endif
+
+#include <boost/svg_plot/svg.hpp>
+ using boost::svg::svg;
+
+#include <boost/svg_plot/svg_1d_plot.hpp>
+ using boost::svg::svg_1d_plot;
+
+#include <boost/svg_plot/svg_boxplot.hpp>
+ using boost::svg::svg_boxplot;
#include <vector>
-#include <cmath>
+ using std::vector;
#include <iostream>
-
-using std::multimap;
-using std::vector;
+ using std::cout;
+ using std::cin;
+ using std::endl;
+#include <cmath>
double h(double x)
{
- return 50 / (x);
+ return 5 / (x);
}
double f(double x)
@@ -18,32 +46,47 @@
return 40 + 25 * sin(x * 50);
}
-using std::cout;
-using std::cin;
-
int main()
{
using namespace boost::svg;
std::vector<double> data1, data2;
+ for(double i= 0.1; i < 3; i += .1)
+ {
+ data1.push_back(h(i));
+ data2.push_back(f(i));
+ }
- svg_boxplot my_plot;
svg_1d_plot my_1d_plot;
- my_1d_plot.load_stylesheet("D:\\style.css");
+ my_1d_plot.title("Boxplots of Common Functions")
+ .x_autoscale(data1);
+ my_1d_plot.plot(data1, "[50 / x]");
+ my_1d_plot.plot(data2, "[40 + 25 * sin(50x)]").stroke_color(red);
+
+ my_1d_plot.write("./svg_test.svg");
- my_1d_plot.background_border_color(black)
- .title("Boxplots of Common Functions");
-
- for(double i=.1; i < 10; i+=.1)
- {
- data1.push_back(h(i));
- data2.push_back(f(i));
- }
+ svg_boxplot my_boxplot;
- my_1d_plot.plot(data1, "[50 / x]");
- my_1d_plot.plot(data2, "[40 + 25 * sin(50x)]");
+ //my_boxplot.y_range(0, 100) // Y-Axis information.
+ //.y_minor_tick_length(10)
+ //.y_major_interval(20);
+
+ my_boxplot.y_autoscale(data2);
- my_1d_plot.write("D:\\1d_test.svg");
+ my_boxplot.plot(data1, "[50 / x]");
+ my_boxplot.plot(data2, "[40 + 25 * sin(50x)]");
+ my_boxplot.write("./svg_test_box.svg");
return 0;
-}
+} // int main()
+
+/*
+
+Output:
+
+svg_test.cpp
+Linking...
+Embedding manifest...
+Autorun "j:\Cpp\SVG\Debug\svg_test.exe
+
+*/
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