20 #include "ns3/gnuplot.h"
35 std::string fileNameWithNoExtension =
"plot-2d";
36 std::string graphicsFileName = fileNameWithNoExtension +
".png";
37 std::string plotFileName = fileNameWithNoExtension +
".plt";
38 std::string plotTitle =
"2-D Plot";
39 std::string dataTitle =
"2-D Data";
65 for (
x = -5.0;
x <= +5.0;
x += 1.0)
82 std::ofstream plotFile(plotFileName);
97 std::string fileNameWithNoExtension =
"plot-2d-with-error-bars";
98 std::string graphicsFileName = fileNameWithNoExtension +
".png";
99 std::string plotFileName = fileNameWithNoExtension +
".plt";
100 std::string plotTitle =
"2-D Plot With Error Bars";
101 std::string dataTitle =
"2-D Data With Error Bars";
104 Gnuplot plot(graphicsFileName);
132 for (
x = -5.0;
x <= +5.0;
x += 1.0)
145 yErrorDelta = 0.1 * y;
149 dataset.
Add(
x, y, xErrorDelta, yErrorDelta);
156 std::ofstream plotFile(plotFileName);
171 std::string fileNameWithNoExtension =
"plot-3d";
172 std::string graphicsFileName = fileNameWithNoExtension +
".png";
173 std::string plotFileName = fileNameWithNoExtension +
".plt";
174 std::string plotTitle =
"3-D Plot";
175 std::string dataTitle =
"3-D Data";
178 Gnuplot plot(graphicsFileName);
212 for (
x = -5.0;
x <= +5.0;
x += 1.0)
214 for (y = -5.0; y <= +5.0; y += 1.0)
224 dataset.
Add(
x, y, z);
236 std::ofstream plotFile(plotFileName);
248 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.