Hey everybody!
I just found the option to use gnuplot
with ns3. Only problem I got is that I can not figure it out to plot multiple plots in one diagram, which I can do with gnuplot itself. The code I use is similar to this simple example:
//datasets
Gnuplot2dDataset data1;
Gnuplot2dDataset data2;
//random data
data1.Add(Simulator::Now ().GetSeconds (), value11);
data1.Add(Simulator::Now ().GetSeconds (), value12);
data2.Add(Simulator::Now ().GetSeconds (), value21);
data2.Add(Simulator::Now ().GetSeconds (), value22);
//Gnuplot
Gnuplot plot (diagram + ".png");
plot.SetTerminal ("png");
plot.SetLegend ("Time s" , "Number of Packets");
data1.SetTitle("one");
data2.SetTitle("two");
data1.SetStyle(Gnuplot2dDataset::LINES_POINTS);
data2.SetStyle(Gnuplot2dDataset::LINES_POINTS);
plot.AddDataset(data1);
plot.AddDataset(data2);
// Open the plot file.
std::ofstream plotFile ((diagram + ".plt").c_str());
// Write the plot file.
plot.GenerateOutput (plotFile);
// Close the plot file.
plotFile.close ();
There is no diagram generated at all and when I try to gnuplot the .plt file I get the following error:
plot '-' title 'sent' with linespoints, '-' title 'failed' with linespoints
^
"Diagramm.plt", line 6: warning: Skipping data file with no valid points
The related .plt looks like this:
set terminal png
set output 'Diagramm.png'
set xlabel 'Time s'
set ylabel 'Number of Packets'
plot '-' title 'sent' with linespoints, '-' title 'failed' with linespoints
e
1.089 1
1.276 2
1.383 3
1.7 4
1.755 5
2.232 6
2.458 7
2.59 8
3 9
3.922 10
e
When using just one plot thus calling the AddDataset() just once everything works fine and I can even use the .plt file to generate the same diagram as the script does with gnuplot.
I appreciate every help and greets!