23 #include "ns3/gnuplot.h" 38 std::string fileNameWithNoExtension =
"plot-2d";
39 std::string graphicsFileName = fileNameWithNoExtension +
".png";
40 std::string plotFileName = fileNameWithNoExtension +
".plt";
41 std::string plotTitle =
"2-D Plot";
42 std::string dataTitle =
"2-D Data";
45 Gnuplot plot (graphicsFileName);
68 for (
x = -5.0;
x <= +5.0;
x += 1.0)
85 std::ofstream plotFile (plotFileName.c_str());
104 std::string fileNameWithNoExtension =
"plot-2d-with-error-bars";
105 std::string graphicsFileName = fileNameWithNoExtension +
".png";
106 std::string plotFileName = fileNameWithNoExtension +
".plt";
107 std::string plotTitle =
"2-D Plot With Error Bars";
108 std::string dataTitle =
"2-D Data With Error Bars";
111 Gnuplot plot (graphicsFileName);
139 for (
x = -5.0;
x <= +5.0;
x += 1.0)
152 yErrorDelta = 0.1 * y;
156 dataset.
Add (
x, y, xErrorDelta, yErrorDelta);
163 std::ofstream plotFile (plotFileName.c_str());
182 std::string fileNameWithNoExtension =
"plot-3d";
183 std::string graphicsFileName = fileNameWithNoExtension +
".png";
184 std::string plotFileName = fileNameWithNoExtension +
".plt";
185 std::string plotTitle =
"3-D Plot";
186 std::string dataTitle =
"3-D Data";
189 Gnuplot plot (graphicsFileName);
223 for (
x = -5.0;
x <= +5.0;
x += 1.0)
225 for (y = -5.0; y <= +5.0; y += 1.0)
235 dataset.
Add (
x, y, z);
247 std::ofstream plotFile (plotFileName.c_str());
259 int main (
int argc,
char *argv[])
void AppendExtra(const std::string &extra)
Class to represent a 3D points plot.
Class to represent a 2D points plot.
void SetTitle(const std::string &title)
Change line title.
void Create2DPlotWithErrorBarsFile()
void Add(double x, double y, double z)
void AddDataset(const GnuplotDataset &dataset)
void SetErrorBars(enum ErrorBars errorBars)
a simple class to generate gnuplot-ready plotting commands from a set of datasets.
void SetTitle(const std::string &title)
void AddEmptyLine()
Add an empty line in the data output sequence.
void GenerateOutput(std::ostream &os)
Writes gnuplot commands and data values to a single output stream.
void Add(double x, double y)
void SetLegend(const std::string &xLegend, const std::string &yLegend)
Every class exported by the ns3 library is enclosed in the ns3 namespace.
void SetStyle(enum Style style)
void SetStyle(const std::string &style)
void SetTerminal(const std::string &terminal)