author | Vedran Miletić <rivanvx@gmail.com> |
Sat, 01 Sep 2012 20:57:21 +0200 | |
changeset 9063 | 32755d0516f4 |
parent 7481 | e52db23c9c8b |
permissions | -rw-r--r-- |
7477
4764c1472bd6
Fix bug in gnuplot error bars and create gnuplot example
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
1 |
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ |
4764c1472bd6
Fix bug in gnuplot error bars and create gnuplot example
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
2 |
/* |
4764c1472bd6
Fix bug in gnuplot error bars and create gnuplot example
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
3 |
* Copyright (c) 2011 University of Washington |
4764c1472bd6
Fix bug in gnuplot error bars and create gnuplot example
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
4 |
* |
4764c1472bd6
Fix bug in gnuplot error bars and create gnuplot example
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
5 |
* This program is free software; you can redistribute it and/or modify |
4764c1472bd6
Fix bug in gnuplot error bars and create gnuplot example
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
6 |
* it under the terms of the GNU General Public License version 2 as |
4764c1472bd6
Fix bug in gnuplot error bars and create gnuplot example
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
7 |
* published by the Free Software Foundation; |
4764c1472bd6
Fix bug in gnuplot error bars and create gnuplot example
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
8 |
* |
4764c1472bd6
Fix bug in gnuplot error bars and create gnuplot example
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
9 |
* This program is distributed in the hope that it will be useful, |
4764c1472bd6
Fix bug in gnuplot error bars and create gnuplot example
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
10 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
4764c1472bd6
Fix bug in gnuplot error bars and create gnuplot example
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
11 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
4764c1472bd6
Fix bug in gnuplot error bars and create gnuplot example
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
12 |
* GNU General Public License for more details. |
4764c1472bd6
Fix bug in gnuplot error bars and create gnuplot example
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
13 |
* |
4764c1472bd6
Fix bug in gnuplot error bars and create gnuplot example
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
14 |
* You should have received a copy of the GNU General Public License |
4764c1472bd6
Fix bug in gnuplot error bars and create gnuplot example
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
15 |
* along with this program; if not, write to the Free Software |
4764c1472bd6
Fix bug in gnuplot error bars and create gnuplot example
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
16 |
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
4764c1472bd6
Fix bug in gnuplot error bars and create gnuplot example
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
17 |
* |
4764c1472bd6
Fix bug in gnuplot error bars and create gnuplot example
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
18 |
* Author: Mitch Watrous (watrous@u.washington.edu) |
4764c1472bd6
Fix bug in gnuplot error bars and create gnuplot example
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
19 |
*/ |
4764c1472bd6
Fix bug in gnuplot error bars and create gnuplot example
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
20 |
|
4764c1472bd6
Fix bug in gnuplot error bars and create gnuplot example
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
21 |
#include <fstream> |
4764c1472bd6
Fix bug in gnuplot error bars and create gnuplot example
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
22 |
|
4764c1472bd6
Fix bug in gnuplot error bars and create gnuplot example
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
23 |
#include "ns3/gnuplot.h" |
4764c1472bd6
Fix bug in gnuplot error bars and create gnuplot example
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
24 |
|
4764c1472bd6
Fix bug in gnuplot error bars and create gnuplot example
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
25 |
using namespace ns3; |
4764c1472bd6
Fix bug in gnuplot error bars and create gnuplot example
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
26 |
|
4764c1472bd6
Fix bug in gnuplot error bars and create gnuplot example
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
27 |
namespace { |
4764c1472bd6
Fix bug in gnuplot error bars and create gnuplot example
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
28 |
|
4764c1472bd6
Fix bug in gnuplot error bars and create gnuplot example
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
29 |
//=========================================================================== |
7481
e52db23c9c8b
Capitalize function names in gnuplot example
Mitch Watrous <watrous@u.washington.edu>
parents:
7478
diff
changeset
|
30 |
// Function: Create2DPlotFile |
7477
4764c1472bd6
Fix bug in gnuplot error bars and create gnuplot example
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
31 |
// |
4764c1472bd6
Fix bug in gnuplot error bars and create gnuplot example
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
32 |
// |
4764c1472bd6
Fix bug in gnuplot error bars and create gnuplot example
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
33 |
// This function creates a 2-D plot file. |
4764c1472bd6
Fix bug in gnuplot error bars and create gnuplot example
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
34 |
//=========================================================================== |
4764c1472bd6
Fix bug in gnuplot error bars and create gnuplot example
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
35 |
|
7481
e52db23c9c8b
Capitalize function names in gnuplot example
Mitch Watrous <watrous@u.washington.edu>
parents:
7478
diff
changeset
|
36 |
void Create2DPlotFile () |
7477
4764c1472bd6
Fix bug in gnuplot error bars and create gnuplot example
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
37 |
{ |
9063
32755d0516f4
Bug 1237 - code cleanups related to includes
Vedran Miletić <rivanvx@gmail.com>
parents:
7481
diff
changeset
|
38 |
std::string fileNameWithNoExtension = "plot-2d"; |
32755d0516f4
Bug 1237 - code cleanups related to includes
Vedran Miletić <rivanvx@gmail.com>
parents:
7481
diff
changeset
|
39 |
std::string graphicsFileName = fileNameWithNoExtension + ".png"; |
32755d0516f4
Bug 1237 - code cleanups related to includes
Vedran Miletić <rivanvx@gmail.com>
parents:
7481
diff
changeset
|
40 |
std::string plotFileName = fileNameWithNoExtension + ".plt"; |
32755d0516f4
Bug 1237 - code cleanups related to includes
Vedran Miletić <rivanvx@gmail.com>
parents:
7481
diff
changeset
|
41 |
std::string plotTitle = "2-D Plot"; |
32755d0516f4
Bug 1237 - code cleanups related to includes
Vedran Miletić <rivanvx@gmail.com>
parents:
7481
diff
changeset
|
42 |
std::string dataTitle = "2-D Data"; |
7477
4764c1472bd6
Fix bug in gnuplot error bars and create gnuplot example
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
43 |
|
4764c1472bd6
Fix bug in gnuplot error bars and create gnuplot example
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
44 |
// Instantiate the plot and set its title. |
4764c1472bd6
Fix bug in gnuplot error bars and create gnuplot example
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
45 |
Gnuplot plot (graphicsFileName); |
4764c1472bd6
Fix bug in gnuplot error bars and create gnuplot example
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
46 |
plot.SetTitle (plotTitle); |
4764c1472bd6
Fix bug in gnuplot error bars and create gnuplot example
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
47 |
|
4764c1472bd6
Fix bug in gnuplot error bars and create gnuplot example
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
48 |
// Make the graphics file, which the plot file will create when it |
4764c1472bd6
Fix bug in gnuplot error bars and create gnuplot example
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
49 |
// is used with Gnuplot, be a PNG file. |
4764c1472bd6
Fix bug in gnuplot error bars and create gnuplot example
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
50 |
plot.SetTerminal ("png"); |
4764c1472bd6
Fix bug in gnuplot error bars and create gnuplot example
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
51 |
|
4764c1472bd6
Fix bug in gnuplot error bars and create gnuplot example
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
52 |
// Set the labels for each axis. |
4764c1472bd6
Fix bug in gnuplot error bars and create gnuplot example
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
53 |
plot.SetLegend ("X Values", "Y Values"); |
4764c1472bd6
Fix bug in gnuplot error bars and create gnuplot example
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
54 |
|
4764c1472bd6
Fix bug in gnuplot error bars and create gnuplot example
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
55 |
// Set the range for the x axis. |
4764c1472bd6
Fix bug in gnuplot error bars and create gnuplot example
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
56 |
plot.AppendExtra ("set xrange [-6:+6]"); |
4764c1472bd6
Fix bug in gnuplot error bars and create gnuplot example
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
57 |
|
4764c1472bd6
Fix bug in gnuplot error bars and create gnuplot example
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
58 |
// Instantiate the dataset, set its title, and make the points be |
4764c1472bd6
Fix bug in gnuplot error bars and create gnuplot example
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
59 |
// plotted along with connecting lines. |
4764c1472bd6
Fix bug in gnuplot error bars and create gnuplot example
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
60 |
Gnuplot2dDataset dataset; |
4764c1472bd6
Fix bug in gnuplot error bars and create gnuplot example
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
61 |
dataset.SetTitle (dataTitle); |
4764c1472bd6
Fix bug in gnuplot error bars and create gnuplot example
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
62 |
dataset.SetStyle (Gnuplot2dDataset::LINES_POINTS); |
4764c1472bd6
Fix bug in gnuplot error bars and create gnuplot example
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
63 |
|
4764c1472bd6
Fix bug in gnuplot error bars and create gnuplot example
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
64 |
double x; |
4764c1472bd6
Fix bug in gnuplot error bars and create gnuplot example
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
65 |
double y; |
4764c1472bd6
Fix bug in gnuplot error bars and create gnuplot example
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
66 |
|
4764c1472bd6
Fix bug in gnuplot error bars and create gnuplot example
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
67 |
// Create the 2-D dataset. |
4764c1472bd6
Fix bug in gnuplot error bars and create gnuplot example
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
68 |
for (x = -5.0; x <= +5.0; x += 1.0) |
4764c1472bd6
Fix bug in gnuplot error bars and create gnuplot example
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
69 |
{ |
4764c1472bd6
Fix bug in gnuplot error bars and create gnuplot example
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
70 |
// Calculate the 2-D curve |
4764c1472bd6
Fix bug in gnuplot error bars and create gnuplot example
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
71 |
// |
4764c1472bd6
Fix bug in gnuplot error bars and create gnuplot example
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
72 |
// 2 |
4764c1472bd6
Fix bug in gnuplot error bars and create gnuplot example
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
73 |
// y = x . |
4764c1472bd6
Fix bug in gnuplot error bars and create gnuplot example
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
74 |
// |
4764c1472bd6
Fix bug in gnuplot error bars and create gnuplot example
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
75 |
y = x * x; |
4764c1472bd6
Fix bug in gnuplot error bars and create gnuplot example
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
76 |
|
4764c1472bd6
Fix bug in gnuplot error bars and create gnuplot example
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
77 |
// Add this point. |
4764c1472bd6
Fix bug in gnuplot error bars and create gnuplot example
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
78 |
dataset.Add (x, y); |
4764c1472bd6
Fix bug in gnuplot error bars and create gnuplot example
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
79 |
} |
4764c1472bd6
Fix bug in gnuplot error bars and create gnuplot example
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
80 |
|
4764c1472bd6
Fix bug in gnuplot error bars and create gnuplot example
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
81 |
// Add the dataset to the plot. |
4764c1472bd6
Fix bug in gnuplot error bars and create gnuplot example
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
82 |
plot.AddDataset (dataset); |
4764c1472bd6
Fix bug in gnuplot error bars and create gnuplot example
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
83 |
|
4764c1472bd6
Fix bug in gnuplot error bars and create gnuplot example
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
84 |
// Open the plot file. |
9063
32755d0516f4
Bug 1237 - code cleanups related to includes
Vedran Miletić <rivanvx@gmail.com>
parents:
7481
diff
changeset
|
85 |
std::ofstream plotFile (plotFileName.c_str()); |
7477
4764c1472bd6
Fix bug in gnuplot error bars and create gnuplot example
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
86 |
|
4764c1472bd6
Fix bug in gnuplot error bars and create gnuplot example
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
87 |
// Write the plot file. |
4764c1472bd6
Fix bug in gnuplot error bars and create gnuplot example
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
88 |
plot.GenerateOutput (plotFile); |
4764c1472bd6
Fix bug in gnuplot error bars and create gnuplot example
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
89 |
|
4764c1472bd6
Fix bug in gnuplot error bars and create gnuplot example
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
90 |
// Close the plot file. |
4764c1472bd6
Fix bug in gnuplot error bars and create gnuplot example
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
91 |
plotFile.close (); |
4764c1472bd6
Fix bug in gnuplot error bars and create gnuplot example
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
92 |
} |
4764c1472bd6
Fix bug in gnuplot error bars and create gnuplot example
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
93 |
|
4764c1472bd6
Fix bug in gnuplot error bars and create gnuplot example
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
94 |
|
4764c1472bd6
Fix bug in gnuplot error bars and create gnuplot example
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
95 |
//=========================================================================== |
7481
e52db23c9c8b
Capitalize function names in gnuplot example
Mitch Watrous <watrous@u.washington.edu>
parents:
7478
diff
changeset
|
96 |
// Function: Create2DPlotWithErrorBarsFile |
7477
4764c1472bd6
Fix bug in gnuplot error bars and create gnuplot example
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
97 |
// |
4764c1472bd6
Fix bug in gnuplot error bars and create gnuplot example
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
98 |
// |
4764c1472bd6
Fix bug in gnuplot error bars and create gnuplot example
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
99 |
// This function creates a 2-D plot with error bars file. |
4764c1472bd6
Fix bug in gnuplot error bars and create gnuplot example
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
100 |
//=========================================================================== |
4764c1472bd6
Fix bug in gnuplot error bars and create gnuplot example
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
101 |
|
7481
e52db23c9c8b
Capitalize function names in gnuplot example
Mitch Watrous <watrous@u.washington.edu>
parents:
7478
diff
changeset
|
102 |
void Create2DPlotWithErrorBarsFile () |
7477
4764c1472bd6
Fix bug in gnuplot error bars and create gnuplot example
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
103 |
{ |
9063
32755d0516f4
Bug 1237 - code cleanups related to includes
Vedran Miletić <rivanvx@gmail.com>
parents:
7481
diff
changeset
|
104 |
std::string fileNameWithNoExtension = "plot-2d-with-error-bars"; |
32755d0516f4
Bug 1237 - code cleanups related to includes
Vedran Miletić <rivanvx@gmail.com>
parents:
7481
diff
changeset
|
105 |
std::string graphicsFileName = fileNameWithNoExtension + ".png"; |
32755d0516f4
Bug 1237 - code cleanups related to includes
Vedran Miletić <rivanvx@gmail.com>
parents:
7481
diff
changeset
|
106 |
std::string plotFileName = fileNameWithNoExtension + ".plt"; |
32755d0516f4
Bug 1237 - code cleanups related to includes
Vedran Miletić <rivanvx@gmail.com>
parents:
7481
diff
changeset
|
107 |
std::string plotTitle = "2-D Plot With Error Bars"; |
32755d0516f4
Bug 1237 - code cleanups related to includes
Vedran Miletić <rivanvx@gmail.com>
parents:
7481
diff
changeset
|
108 |
std::string dataTitle = "2-D Data With Error Bars"; |
7477
4764c1472bd6
Fix bug in gnuplot error bars and create gnuplot example
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
109 |
|
4764c1472bd6
Fix bug in gnuplot error bars and create gnuplot example
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
110 |
// Instantiate the plot and set its title. |
4764c1472bd6
Fix bug in gnuplot error bars and create gnuplot example
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
111 |
Gnuplot plot (graphicsFileName); |
4764c1472bd6
Fix bug in gnuplot error bars and create gnuplot example
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
112 |
plot.SetTitle (plotTitle); |
4764c1472bd6
Fix bug in gnuplot error bars and create gnuplot example
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
113 |
|
4764c1472bd6
Fix bug in gnuplot error bars and create gnuplot example
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
114 |
// Make the graphics file, which the plot file will create when it |
4764c1472bd6
Fix bug in gnuplot error bars and create gnuplot example
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
115 |
// is used with Gnuplot, be a PNG file. |
4764c1472bd6
Fix bug in gnuplot error bars and create gnuplot example
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
116 |
plot.SetTerminal ("png"); |
4764c1472bd6
Fix bug in gnuplot error bars and create gnuplot example
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
117 |
|
4764c1472bd6
Fix bug in gnuplot error bars and create gnuplot example
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
118 |
// Set the labels for each axis. |
4764c1472bd6
Fix bug in gnuplot error bars and create gnuplot example
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
119 |
plot.SetLegend ("X Values", "Y Values"); |
4764c1472bd6
Fix bug in gnuplot error bars and create gnuplot example
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
120 |
|
4764c1472bd6
Fix bug in gnuplot error bars and create gnuplot example
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
121 |
// Set the range for the x axis. |
4764c1472bd6
Fix bug in gnuplot error bars and create gnuplot example
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
122 |
plot.AppendExtra ("set xrange [-6:+6]"); |
4764c1472bd6
Fix bug in gnuplot error bars and create gnuplot example
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
123 |
|
4764c1472bd6
Fix bug in gnuplot error bars and create gnuplot example
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
124 |
// Instantiate the dataset, set its title, and make the points be |
4764c1472bd6
Fix bug in gnuplot error bars and create gnuplot example
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
125 |
// plotted with no connecting lines. |
4764c1472bd6
Fix bug in gnuplot error bars and create gnuplot example
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
126 |
Gnuplot2dDataset dataset; |
4764c1472bd6
Fix bug in gnuplot error bars and create gnuplot example
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
127 |
dataset.SetTitle (dataTitle); |
4764c1472bd6
Fix bug in gnuplot error bars and create gnuplot example
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
128 |
dataset.SetStyle (Gnuplot2dDataset::POINTS); |
4764c1472bd6
Fix bug in gnuplot error bars and create gnuplot example
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
129 |
|
4764c1472bd6
Fix bug in gnuplot error bars and create gnuplot example
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
130 |
// Make the dataset have error bars in both the x and y directions. |
4764c1472bd6
Fix bug in gnuplot error bars and create gnuplot example
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
131 |
dataset.SetErrorBars (Gnuplot2dDataset::XY); |
4764c1472bd6
Fix bug in gnuplot error bars and create gnuplot example
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
132 |
|
4764c1472bd6
Fix bug in gnuplot error bars and create gnuplot example
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
133 |
double x; |
4764c1472bd6
Fix bug in gnuplot error bars and create gnuplot example
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
134 |
double xErrorDelta; |
4764c1472bd6
Fix bug in gnuplot error bars and create gnuplot example
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
135 |
double y; |
4764c1472bd6
Fix bug in gnuplot error bars and create gnuplot example
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
136 |
double yErrorDelta; |
4764c1472bd6
Fix bug in gnuplot error bars and create gnuplot example
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
137 |
|
4764c1472bd6
Fix bug in gnuplot error bars and create gnuplot example
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
138 |
// Create the 2-D dataset. |
4764c1472bd6
Fix bug in gnuplot error bars and create gnuplot example
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
139 |
for (x = -5.0; x <= +5.0; x += 1.0) |
4764c1472bd6
Fix bug in gnuplot error bars and create gnuplot example
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
140 |
{ |
4764c1472bd6
Fix bug in gnuplot error bars and create gnuplot example
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
141 |
// Calculate the 2-D curve |
4764c1472bd6
Fix bug in gnuplot error bars and create gnuplot example
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
142 |
// |
4764c1472bd6
Fix bug in gnuplot error bars and create gnuplot example
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
143 |
// 2 |
4764c1472bd6
Fix bug in gnuplot error bars and create gnuplot example
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
144 |
// y = x . |
4764c1472bd6
Fix bug in gnuplot error bars and create gnuplot example
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
145 |
// |
4764c1472bd6
Fix bug in gnuplot error bars and create gnuplot example
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
146 |
y = x * x; |
4764c1472bd6
Fix bug in gnuplot error bars and create gnuplot example
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
147 |
|
4764c1472bd6
Fix bug in gnuplot error bars and create gnuplot example
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
148 |
// Make the uncertainty in the x direction be constant and make |
4764c1472bd6
Fix bug in gnuplot error bars and create gnuplot example
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
149 |
// the uncertainty in the y direction be a constant fraction of |
4764c1472bd6
Fix bug in gnuplot error bars and create gnuplot example
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
150 |
// y's value. |
4764c1472bd6
Fix bug in gnuplot error bars and create gnuplot example
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
151 |
xErrorDelta = 0.25; |
4764c1472bd6
Fix bug in gnuplot error bars and create gnuplot example
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
152 |
yErrorDelta = 0.1 * y; |
4764c1472bd6
Fix bug in gnuplot error bars and create gnuplot example
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
153 |
|
4764c1472bd6
Fix bug in gnuplot error bars and create gnuplot example
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
154 |
// Add this point with uncertainties in both the x and y |
4764c1472bd6
Fix bug in gnuplot error bars and create gnuplot example
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
155 |
// direction. |
4764c1472bd6
Fix bug in gnuplot error bars and create gnuplot example
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
156 |
dataset.Add (x, y, xErrorDelta, yErrorDelta); |
4764c1472bd6
Fix bug in gnuplot error bars and create gnuplot example
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
157 |
} |
4764c1472bd6
Fix bug in gnuplot error bars and create gnuplot example
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
158 |
|
4764c1472bd6
Fix bug in gnuplot error bars and create gnuplot example
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
159 |
// Add the dataset to the plot. |
4764c1472bd6
Fix bug in gnuplot error bars and create gnuplot example
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
160 |
plot.AddDataset (dataset); |
4764c1472bd6
Fix bug in gnuplot error bars and create gnuplot example
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
161 |
|
4764c1472bd6
Fix bug in gnuplot error bars and create gnuplot example
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
162 |
// Open the plot file. |
9063
32755d0516f4
Bug 1237 - code cleanups related to includes
Vedran Miletić <rivanvx@gmail.com>
parents:
7481
diff
changeset
|
163 |
std::ofstream plotFile (plotFileName.c_str()); |
7477
4764c1472bd6
Fix bug in gnuplot error bars and create gnuplot example
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
164 |
|
4764c1472bd6
Fix bug in gnuplot error bars and create gnuplot example
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
165 |
// Write the plot file. |
4764c1472bd6
Fix bug in gnuplot error bars and create gnuplot example
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
166 |
plot.GenerateOutput (plotFile); |
4764c1472bd6
Fix bug in gnuplot error bars and create gnuplot example
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
167 |
|
4764c1472bd6
Fix bug in gnuplot error bars and create gnuplot example
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
168 |
// Close the plot file. |
4764c1472bd6
Fix bug in gnuplot error bars and create gnuplot example
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
169 |
plotFile.close (); |
4764c1472bd6
Fix bug in gnuplot error bars and create gnuplot example
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
170 |
} |
4764c1472bd6
Fix bug in gnuplot error bars and create gnuplot example
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
171 |
|
4764c1472bd6
Fix bug in gnuplot error bars and create gnuplot example
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
172 |
|
4764c1472bd6
Fix bug in gnuplot error bars and create gnuplot example
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
173 |
//=========================================================================== |
7481
e52db23c9c8b
Capitalize function names in gnuplot example
Mitch Watrous <watrous@u.washington.edu>
parents:
7478
diff
changeset
|
174 |
// Function: Create3DPlotFile |
7477
4764c1472bd6
Fix bug in gnuplot error bars and create gnuplot example
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
175 |
// |
4764c1472bd6
Fix bug in gnuplot error bars and create gnuplot example
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
176 |
// |
4764c1472bd6
Fix bug in gnuplot error bars and create gnuplot example
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
177 |
// This function creates a 3-D plot file. |
4764c1472bd6
Fix bug in gnuplot error bars and create gnuplot example
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
178 |
//=========================================================================== |
4764c1472bd6
Fix bug in gnuplot error bars and create gnuplot example
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
179 |
|
7481
e52db23c9c8b
Capitalize function names in gnuplot example
Mitch Watrous <watrous@u.washington.edu>
parents:
7478
diff
changeset
|
180 |
void Create3DPlotFile () |
7477
4764c1472bd6
Fix bug in gnuplot error bars and create gnuplot example
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
181 |
{ |
9063
32755d0516f4
Bug 1237 - code cleanups related to includes
Vedran Miletić <rivanvx@gmail.com>
parents:
7481
diff
changeset
|
182 |
std::string fileNameWithNoExtension = "plot-3d"; |
32755d0516f4
Bug 1237 - code cleanups related to includes
Vedran Miletić <rivanvx@gmail.com>
parents:
7481
diff
changeset
|
183 |
std::string graphicsFileName = fileNameWithNoExtension + ".png"; |
32755d0516f4
Bug 1237 - code cleanups related to includes
Vedran Miletić <rivanvx@gmail.com>
parents:
7481
diff
changeset
|
184 |
std::string plotFileName = fileNameWithNoExtension + ".plt"; |
32755d0516f4
Bug 1237 - code cleanups related to includes
Vedran Miletić <rivanvx@gmail.com>
parents:
7481
diff
changeset
|
185 |
std::string plotTitle = "3-D Plot"; |
32755d0516f4
Bug 1237 - code cleanups related to includes
Vedran Miletić <rivanvx@gmail.com>
parents:
7481
diff
changeset
|
186 |
std::string dataTitle = "3-D Data"; |
7477
4764c1472bd6
Fix bug in gnuplot error bars and create gnuplot example
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
187 |
|
4764c1472bd6
Fix bug in gnuplot error bars and create gnuplot example
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
188 |
// Instantiate the plot and set its title. |
4764c1472bd6
Fix bug in gnuplot error bars and create gnuplot example
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
189 |
Gnuplot plot (graphicsFileName); |
4764c1472bd6
Fix bug in gnuplot error bars and create gnuplot example
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
190 |
plot.SetTitle (plotTitle); |
4764c1472bd6
Fix bug in gnuplot error bars and create gnuplot example
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
191 |
|
4764c1472bd6
Fix bug in gnuplot error bars and create gnuplot example
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
192 |
// Make the graphics file, which the plot file will create when it |
4764c1472bd6
Fix bug in gnuplot error bars and create gnuplot example
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
193 |
// is used with Gnuplot, be a PNG file. |
4764c1472bd6
Fix bug in gnuplot error bars and create gnuplot example
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
194 |
plot.SetTerminal ("png"); |
4764c1472bd6
Fix bug in gnuplot error bars and create gnuplot example
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
195 |
|
4764c1472bd6
Fix bug in gnuplot error bars and create gnuplot example
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
196 |
// Rotate the plot 30 degrees around the x axis and then rotate the |
4764c1472bd6
Fix bug in gnuplot error bars and create gnuplot example
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
197 |
// plot 120 degrees around the new z axis. |
4764c1472bd6
Fix bug in gnuplot error bars and create gnuplot example
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
198 |
plot.AppendExtra ("set view 30, 120, 1.0, 1.0"); |
4764c1472bd6
Fix bug in gnuplot error bars and create gnuplot example
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
199 |
|
7478
768d1500f0c1
Add Gnuplot section to ns-3 Manual
Mitch Watrous <watrous@u.washington.edu>
parents:
7477
diff
changeset
|
200 |
// Make the zero for the z-axis be in the x-axis and y-axis plane. |
7477
4764c1472bd6
Fix bug in gnuplot error bars and create gnuplot example
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
201 |
plot.AppendExtra ("set ticslevel 0"); |
4764c1472bd6
Fix bug in gnuplot error bars and create gnuplot example
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
202 |
|
4764c1472bd6
Fix bug in gnuplot error bars and create gnuplot example
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
203 |
// Set the labels for each axis. |
4764c1472bd6
Fix bug in gnuplot error bars and create gnuplot example
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
204 |
plot.AppendExtra ("set xlabel 'X Values'"); |
4764c1472bd6
Fix bug in gnuplot error bars and create gnuplot example
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
205 |
plot.AppendExtra ("set ylabel 'Y Values'"); |
4764c1472bd6
Fix bug in gnuplot error bars and create gnuplot example
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
206 |
plot.AppendExtra ("set zlabel 'Z Values'"); |
4764c1472bd6
Fix bug in gnuplot error bars and create gnuplot example
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
207 |
|
4764c1472bd6
Fix bug in gnuplot error bars and create gnuplot example
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
208 |
// Set the ranges for the x and y axis. |
4764c1472bd6
Fix bug in gnuplot error bars and create gnuplot example
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
209 |
plot.AppendExtra ("set xrange [-5:+5]"); |
4764c1472bd6
Fix bug in gnuplot error bars and create gnuplot example
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
210 |
plot.AppendExtra ("set yrange [-5:+5]"); |
4764c1472bd6
Fix bug in gnuplot error bars and create gnuplot example
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
211 |
|
4764c1472bd6
Fix bug in gnuplot error bars and create gnuplot example
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
212 |
// Instantiate the dataset, set its title, and make the points be |
4764c1472bd6
Fix bug in gnuplot error bars and create gnuplot example
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
213 |
// connected by lines. |
4764c1472bd6
Fix bug in gnuplot error bars and create gnuplot example
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
214 |
Gnuplot3dDataset dataset; |
4764c1472bd6
Fix bug in gnuplot error bars and create gnuplot example
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
215 |
dataset.SetTitle (dataTitle); |
4764c1472bd6
Fix bug in gnuplot error bars and create gnuplot example
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
216 |
dataset.SetStyle ("with lines"); |
4764c1472bd6
Fix bug in gnuplot error bars and create gnuplot example
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
217 |
|
4764c1472bd6
Fix bug in gnuplot error bars and create gnuplot example
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
218 |
double x; |
4764c1472bd6
Fix bug in gnuplot error bars and create gnuplot example
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
219 |
double y; |
4764c1472bd6
Fix bug in gnuplot error bars and create gnuplot example
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
220 |
double z; |
4764c1472bd6
Fix bug in gnuplot error bars and create gnuplot example
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
221 |
|
4764c1472bd6
Fix bug in gnuplot error bars and create gnuplot example
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
222 |
// Create the 3-D dataset. |
4764c1472bd6
Fix bug in gnuplot error bars and create gnuplot example
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
223 |
for (x = -5.0; x <= +5.0; x += 1.0) |
4764c1472bd6
Fix bug in gnuplot error bars and create gnuplot example
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
224 |
{ |
4764c1472bd6
Fix bug in gnuplot error bars and create gnuplot example
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
225 |
for (y = -5.0; y <= +5.0; y += 1.0) |
4764c1472bd6
Fix bug in gnuplot error bars and create gnuplot example
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
226 |
{ |
4764c1472bd6
Fix bug in gnuplot error bars and create gnuplot example
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
227 |
// Calculate the 3-D surface |
4764c1472bd6
Fix bug in gnuplot error bars and create gnuplot example
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
228 |
// |
4764c1472bd6
Fix bug in gnuplot error bars and create gnuplot example
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
229 |
// 2 2 |
4764c1472bd6
Fix bug in gnuplot error bars and create gnuplot example
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
230 |
// z = x * y . |
4764c1472bd6
Fix bug in gnuplot error bars and create gnuplot example
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
231 |
// |
4764c1472bd6
Fix bug in gnuplot error bars and create gnuplot example
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
232 |
z = x * x * y * y; |
4764c1472bd6
Fix bug in gnuplot error bars and create gnuplot example
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
233 |
|
4764c1472bd6
Fix bug in gnuplot error bars and create gnuplot example
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
234 |
// Add this point. |
4764c1472bd6
Fix bug in gnuplot error bars and create gnuplot example
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
235 |
dataset.Add (x, y, z); |
4764c1472bd6
Fix bug in gnuplot error bars and create gnuplot example
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
236 |
} |
4764c1472bd6
Fix bug in gnuplot error bars and create gnuplot example
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
237 |
|
4764c1472bd6
Fix bug in gnuplot error bars and create gnuplot example
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
238 |
// The blank line is necessary at the end of each x value's data |
4764c1472bd6
Fix bug in gnuplot error bars and create gnuplot example
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
239 |
// points for the 3-D surface grid to work. |
4764c1472bd6
Fix bug in gnuplot error bars and create gnuplot example
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
240 |
dataset.AddEmptyLine (); |
4764c1472bd6
Fix bug in gnuplot error bars and create gnuplot example
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
241 |
} |
4764c1472bd6
Fix bug in gnuplot error bars and create gnuplot example
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
242 |
|
4764c1472bd6
Fix bug in gnuplot error bars and create gnuplot example
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
243 |
// Add the dataset to the plot. |
4764c1472bd6
Fix bug in gnuplot error bars and create gnuplot example
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
244 |
plot.AddDataset (dataset); |
4764c1472bd6
Fix bug in gnuplot error bars and create gnuplot example
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
245 |
|
4764c1472bd6
Fix bug in gnuplot error bars and create gnuplot example
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
246 |
// Open the plot file. |
9063
32755d0516f4
Bug 1237 - code cleanups related to includes
Vedran Miletić <rivanvx@gmail.com>
parents:
7481
diff
changeset
|
247 |
std::ofstream plotFile (plotFileName.c_str()); |
7477
4764c1472bd6
Fix bug in gnuplot error bars and create gnuplot example
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
248 |
|
4764c1472bd6
Fix bug in gnuplot error bars and create gnuplot example
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
249 |
// Write the plot file. |
4764c1472bd6
Fix bug in gnuplot error bars and create gnuplot example
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
250 |
plot.GenerateOutput (plotFile); |
4764c1472bd6
Fix bug in gnuplot error bars and create gnuplot example
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
251 |
|
4764c1472bd6
Fix bug in gnuplot error bars and create gnuplot example
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
252 |
// Close the plot file. |
4764c1472bd6
Fix bug in gnuplot error bars and create gnuplot example
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
253 |
plotFile.close (); |
4764c1472bd6
Fix bug in gnuplot error bars and create gnuplot example
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
254 |
} |
4764c1472bd6
Fix bug in gnuplot error bars and create gnuplot example
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
255 |
|
4764c1472bd6
Fix bug in gnuplot error bars and create gnuplot example
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
256 |
} // anonymous namespace |
4764c1472bd6
Fix bug in gnuplot error bars and create gnuplot example
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
257 |
|
4764c1472bd6
Fix bug in gnuplot error bars and create gnuplot example
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
258 |
|
4764c1472bd6
Fix bug in gnuplot error bars and create gnuplot example
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
259 |
int main (int argc, char *argv[]) |
4764c1472bd6
Fix bug in gnuplot error bars and create gnuplot example
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
260 |
{ |
4764c1472bd6
Fix bug in gnuplot error bars and create gnuplot example
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
261 |
// Create a 2-D plot file. |
7481
e52db23c9c8b
Capitalize function names in gnuplot example
Mitch Watrous <watrous@u.washington.edu>
parents:
7478
diff
changeset
|
262 |
Create2DPlotFile(); |
7477
4764c1472bd6
Fix bug in gnuplot error bars and create gnuplot example
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
263 |
|
4764c1472bd6
Fix bug in gnuplot error bars and create gnuplot example
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
264 |
// Create a 2-D plot with error bars file. |
7481
e52db23c9c8b
Capitalize function names in gnuplot example
Mitch Watrous <watrous@u.washington.edu>
parents:
7478
diff
changeset
|
265 |
Create2DPlotWithErrorBarsFile(); |
7477
4764c1472bd6
Fix bug in gnuplot error bars and create gnuplot example
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
266 |
|
4764c1472bd6
Fix bug in gnuplot error bars and create gnuplot example
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
267 |
// Create a 3-D plot file. |
7481
e52db23c9c8b
Capitalize function names in gnuplot example
Mitch Watrous <watrous@u.washington.edu>
parents:
7478
diff
changeset
|
268 |
Create3DPlotFile(); |
7477
4764c1472bd6
Fix bug in gnuplot error bars and create gnuplot example
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
269 |
|
4764c1472bd6
Fix bug in gnuplot error bars and create gnuplot example
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
270 |
return 0; |
4764c1472bd6
Fix bug in gnuplot error bars and create gnuplot example
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
271 |
} |