23 #include "ns3/gnuplot.h"
34 std::string fileNameWithNoExtension =
"plot-2d";
35 std::string graphicsFileName = fileNameWithNoExtension +
".png";
36 std::string plotFileName = fileNameWithNoExtension +
".plt";
37 std::string plotTitle =
"2-D Plot";
38 std::string dataTitle =
"2-D Data";
41 Gnuplot plot (graphicsFileName);
64 for (
x = -5.0;
x <= +5.0;
x += 1.0)
81 std::ofstream plotFile (plotFileName.c_str());
96 std::string fileNameWithNoExtension =
"plot-2d-with-error-bars";
97 std::string graphicsFileName = fileNameWithNoExtension +
".png";
98 std::string plotFileName = fileNameWithNoExtension +
".plt";
99 std::string plotTitle =
"2-D Plot With Error Bars";
100 std::string dataTitle =
"2-D Data With Error Bars";
103 Gnuplot plot (graphicsFileName);
131 for (
x = -5.0;
x <= +5.0;
x += 1.0)
144 yErrorDelta = 0.1 * y;
148 dataset.
Add (
x, y, xErrorDelta, yErrorDelta);
155 std::ofstream plotFile (plotFileName.c_str());
170 std::string fileNameWithNoExtension =
"plot-3d";
171 std::string graphicsFileName = fileNameWithNoExtension +
".png";
172 std::string plotFileName = fileNameWithNoExtension +
".plt";
173 std::string plotTitle =
"3-D Plot";
174 std::string dataTitle =
"3-D Data";
177 Gnuplot plot (graphicsFileName);
211 for (
x = -5.0;
x <= +5.0;
x += 1.0)
213 for (y = -5.0; y <= +5.0; y += 1.0)
223 dataset.
Add (
x, y, z);
235 std::ofstream plotFile (plotFileName.c_str());
247 int main (
int argc,
char *argv[])
Class to represent a 2D points plot.
void SetErrorBars(enum ErrorBars errorBars)
void SetStyle(enum Style style)
void Add(double x, double y)
Class to represent a 3D points plot.
void AddEmptyLine()
Add an empty line in the data output sequence.
void Add(double x, double y, double z)
void SetStyle(const std::string &style)
void SetTitle(const std::string &title)
Change line title.
a simple class to generate gnuplot-ready plotting commands from a set of datasets.
void AddDataset(const GnuplotDataset &dataset)
void SetLegend(const std::string &xLegend, const std::string &yLegend)
void SetTerminal(const std::string &terminal)
void AppendExtra(const std::string &extra)
void GenerateOutput(std::ostream &os)
Writes gnuplot commands and data values to a single output stream.
void SetTitle(const std::string &title)
void Create2DPlotWithErrorBarsFile()
This function creates a 2-D plot with error bars file.
void Create3DPlotFile()
This function creates a 3-D plot file.
void Create2DPlotFile()
This function creates a 2-D plot file.
Every class exported by the ns3 library is enclosed in the ns3 namespace.
list x
Random number samples.