A Discrete-Event Network Simulator
API
gnuplot.cc
Go to the documentation of this file.
1/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
2/*
3 * Copyright (c) 2007 INRIA, 2008 Timo Bingmann
4 *
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License version 2 as
7 * published by the Free Software Foundation;
8 *
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13 *
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write to the Free Software
16 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17 *
18 * Original Author: Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
19 * Enhancements: Timo Bingmann <timo.bingmann@student.kit.edu>
20 */
21#include "gnuplot.h"
22#include "ns3/assert.h"
23#include <ostream>
24#include <stdexcept>
25
26namespace ns3 {
27
28// --- GnuplotDataset::Data ------------------------------------------------ //
29
37{
38 // *** Data Variables ***
39
40 unsigned int m_references;
41
42 std::string m_title;
43 std::string m_extra;
44
49 Data(const std::string& title);
50
52 virtual ~Data();
53
58 virtual std::string GetCommand () const = 0;
59
74 virtual void PrintExpression (std::ostream &os,
75 bool generateOneOutputFile,
76 unsigned int dataFileDatasetIndex,
77 std::string &dataFileName) const = 0;
78
86 virtual void PrintDataFile (std::ostream &os, bool generateOneOutputFile) const = 0;
87
92 virtual bool IsEmpty () const = 0;
93};
94
95GnuplotDataset::Data::Data(const std::string& title)
96 : m_references (1),
97 m_title (title),
98 m_extra (m_defaultExtra)
99{
100}
101
103{
104}
105
106// --- GnuplotDataset ------------------------------------------------------ //
107
108std::string GnuplotDataset::m_defaultExtra = "";
109
111 : m_data (data)
112{
113}
114
116 : m_data (original.m_data)
117{
119}
120
122{
123 if (--m_data->m_references == 0)
124 delete m_data;
125}
126
128{
129 if (this != &original)
130 {
131 if (--m_data->m_references == 0)
132 delete m_data;
133
134 m_data = original.m_data;
136 }
137 return *this;
138}
139
140void
141GnuplotDataset::SetTitle (const std::string& title)
142{
143 m_data->m_title = title;
144}
145
146void
147GnuplotDataset::SetDefaultExtra (const std::string& extra)
148{
149 m_defaultExtra = extra;
150}
151void
152GnuplotDataset::SetExtra (const std::string& extra)
153{
154 m_data->m_extra = extra;
155}
156
157// --- Gnuplot2dDataset::Data2d -------------------------------------------- //
158
165{
166 // *** Data Variables ***
167
170
172
177 Data2d(const std::string& title);
178
179 virtual std::string GetCommand () const;
180 virtual void PrintExpression (std::ostream &os,
181 bool generateOneOutputFile,
182 unsigned int dataFileDatasetIndex,
183 std::string &dataFileName) const;
184 virtual void PrintDataFile (std::ostream &os, bool generateOneOutputFile) const;
185 virtual bool IsEmpty () const;
186};
187
188Gnuplot2dDataset::Data2d::Data2d(const std::string& title)
189 : Data (title),
190 m_style (m_defaultStyle),
191 m_errorBars (m_defaultErrorBars)
192{
193}
194
195std::string
197{
198 return "plot";
199}
200
201void
203 bool generateOneOutputFile,
204 unsigned int dataFileDatasetIndex,
205 std::string &dataFileName) const
206{
207 // Print the appropriate thing based on whether separate output and
208 // date files are being generated.
209 if (generateOneOutputFile)
210 {
211 os << "\"-\" ";
212 }
213 else
214 {
215 os << "\"" << dataFileName << "\" index " << dataFileDatasetIndex;
216 }
217
218 if (m_title.size ())
219 os << " title \"" << m_title << "\"";
220
221 switch (m_style) {
222 case LINES:
223 os << " with lines";
224 break;
225 case POINTS:
226 switch (m_errorBars)
227 {
228 case NONE:
229 os << " with points";
230 break;
231 case X:
232 os << " with xerrorbars";
233 break;
234 case Y:
235 os << " with yerrorbars";
236 break;
237 case XY:
238 os << " with xyerrorbars";
239 break;
240 }
241 break;
242 case LINES_POINTS:
243 switch (m_errorBars)
244 {
245 case NONE:
246 os << " with linespoints";
247 break;
248 case X:
249 os << " with errorlines";
250 break;
251 case Y:
252 os << " with yerrorlines";
253 break;
254 case XY:
255 os << " with xyerrorlines";
256 break;
257 }
258 break;
259 case DOTS:
260 os << " with dots";
261 break;
262 case IMPULSES:
263 os << " with impulses";
264 break;
265 case STEPS:
266 os << " with steps";
267 break;
268 case FSTEPS:
269 os << " with fsteps";
270 break;
271 case HISTEPS:
272 os << " with histeps";
273 break;
274 }
275
276 if (m_extra.size ())
277 os << " " << m_extra;
278}
279
280void
281Gnuplot2dDataset::Data2d::PrintDataFile (std::ostream &os, bool generateOneOutputFile) const
282{
283 for (PointSet::const_iterator i = m_pointset.begin ();
284 i != m_pointset.end (); ++i)
285 {
286 if (i->empty) {
287 os << std::endl;
288 continue;
289 }
290
291 switch (m_errorBars) {
292 case NONE:
293 os << i->x << " " << i->y << std::endl;
294 break;
295 case X:
296 os << i->x << " " << i->y << " " << i->dx << std::endl;
297 break;
298 case Y:
299 os << i->x << " " << i->y << " " << i->dy << std::endl;
300 break;
301 case XY:
302 os << i->x << " " << i->y << " " << i->dx << " " << i->dy << std::endl;
303 break;
304 }
305 }
306
307 // Print the appropriate thing based on whether separate output and
308 // date files are being generated.
309 if (generateOneOutputFile)
310 {
311 os << "e" << std::endl;
312 }
313 else
314 {
315 os << std::endl;
316 os << std::endl;
317 }
318}
319
320bool
322{
323 return (m_pointset.size () == 0);
324}
325
326// --- Gnuplot2dDataset ---------------------------------------------------- //
327
332
333Gnuplot2dDataset::Gnuplot2dDataset (const std::string& title)
334 : GnuplotDataset ( new Data2d (title) )
335{
336}
337
338void
340{
341 m_defaultStyle = style;
342}
343void
345{
346 reinterpret_cast<Data2d*>(m_data)->m_style = style;
347}
348
349void
351{
352 m_defaultErrorBars = errorBars;
353}
354void
356{
357 reinterpret_cast<Data2d*>(m_data)->m_errorBars = errorBars;
358}
359
360void
361Gnuplot2dDataset::Add (double x, double y)
362{
363 NS_ASSERT (reinterpret_cast<Data2d*>(m_data)->m_errorBars == NONE);
364
365 struct Point data;
366 data.empty = false;
367 data.x = x;
368 data.y = y;
369 data.dx = 0.0;
370 data.dy = 0.0;
371 reinterpret_cast<Data2d*>(m_data)->m_pointset.push_back (data);
372}
373
374void
375Gnuplot2dDataset::Add (double x, double y, double errorDelta)
376{
377 NS_ASSERT ( reinterpret_cast<Data2d*>(m_data)->m_errorBars == X ||
378 reinterpret_cast<Data2d*>(m_data)->m_errorBars == Y );
379
380 struct Point data;
381 data.empty = false;
382 data.x = x;
383 data.y = y;
384 data.dx = errorDelta;
385 data.dy = errorDelta;
386 reinterpret_cast<Data2d*>(m_data)->m_pointset.push_back (data);
387}
388
389void
390Gnuplot2dDataset::Add (double x, double y, double xErrorDelta, double yErrorDelta)
391{
392 NS_ASSERT ( reinterpret_cast<Data2d*>(m_data)->m_errorBars == XY );
393
394 struct Point data;
395 data.empty = false;
396 data.x = x;
397 data.y = y;
398 data.dx = xErrorDelta;
399 data.dy = yErrorDelta;
400 reinterpret_cast<Data2d*>(m_data)->m_pointset.push_back (data);
401}
402
403void
405{
406 struct Point data;
407 data.empty = true;
408 reinterpret_cast<Data2d*>(m_data)->m_pointset.push_back (data);
409}
410
411// --- Gnuplot2dFunction::Function2d --------------------------------------- //
412
419{
420 // *** Data Variables ***
421
422 std::string m_function;
423
430 Function2d(const std::string& title, const std::string& function);
431
432 virtual std::string GetCommand () const;
433 virtual void PrintExpression (std::ostream &os,
434 bool generateOneOutputFile,
435 unsigned int dataFileDatasetIndex,
436 std::string &dataFileName) const;
437 virtual void PrintDataFile (std::ostream &os, bool generateOneOutputFile) const;
438 virtual bool IsEmpty () const;
439};
440
441Gnuplot2dFunction::Function2d::Function2d(const std::string& title, const std::string& function)
442 : Data (title),
443 m_function (function)
444{
445}
446
447std::string
449{
450 return "plot";
451}
452
453void
455 bool generateOneOutputFile,
456 unsigned int dataFileDatasetIndex,
457 std::string &dataFileName) const
458{
459 os << m_function;
460
461 if (m_title.size ())
462 os << " title \"" << m_title << "\"";
463
464 if (m_extra.size ())
465 os << " " << m_extra;
466}
467
468void
469Gnuplot2dFunction::Function2d::PrintDataFile (std::ostream &os, bool generateOneOutputFile) const
470{
471}
472
473bool
475{
476 return false;
477}
478
479// --- Gnuplot2dFunction --------------------------------------------------- //
480
481Gnuplot2dFunction::Gnuplot2dFunction (const std::string& title, const std::string& function)
482 : GnuplotDataset ( new Function2d (title, function) )
483{
484}
485
486void
487Gnuplot2dFunction::SetFunction (const std::string& function)
488{
489 reinterpret_cast<Function2d*>(m_data)->m_function = function;
490}
491
492// --- Gnuplot3dDataset::Data3d -------------------------------------------- //
493
500{
501 // *** Data Variables ***
502
503 std::string m_style;
504
506
511 Data3d(const std::string& title);
512
513 virtual std::string GetCommand () const;
514 virtual void PrintExpression (std::ostream &os,
515 bool generateOneOutputFile,
516 unsigned int dataFileDatasetIndex,
517 std::string &dataFileName) const;
518 virtual void PrintDataFile (std::ostream &os, bool generateOneOutputFile) const;
519 virtual bool IsEmpty () const;
520};
521
522Gnuplot3dDataset::Data3d::Data3d(const std::string& title)
523 : Data (title),
524 m_style (m_defaultStyle)
525{
526}
527
528std::string
530{
531 return "splot";
532}
533
534void
536 bool generateOneOutputFile,
537 unsigned int dataFileDatasetIndex,
538 std::string &dataFileName) const
539{
540 os << "\"-\" ";
541
542 if (m_style.size ())
543 os << " " << m_style;
544
545 if (m_title.size ())
546 os << " title \"" << m_title << "\"";
547
548 if (m_extra.size ())
549 os << " " << m_extra;
550}
551
552void
553Gnuplot3dDataset::Data3d::PrintDataFile (std::ostream &os, bool generateOneOutputFile) const
554{
555 for (PointSet::const_iterator i = m_pointset.begin ();
556 i != m_pointset.end (); ++i)
557 {
558 if (i->empty) {
559 os << std::endl;
560 continue;
561 }
562
563 os << i->x << " " << i->y << " " << i->z << std::endl;
564 }
565 os << "e" << std::endl;
566}
567
568bool
570{
571 return (m_pointset.size () == 0);
572}
573
574// --- Gnuplot3dDataset ---------------------------------------------------- //
575
576std::string Gnuplot3dDataset::m_defaultStyle = "";
577
578Gnuplot3dDataset::Gnuplot3dDataset (const std::string& title)
579 : GnuplotDataset ( new Data3d (title) )
580{
581}
582
583void
584Gnuplot3dDataset::SetDefaultStyle (const std::string& style)
585{
586 m_defaultStyle = style;
587}
588void
589Gnuplot3dDataset::SetStyle (const std::string& style)
590{
591 reinterpret_cast<Data3d*>(m_data)->m_style = style;
592}
593
594void
595Gnuplot3dDataset::Add (double x, double y, double z)
596{
597 struct Point data;
598 data.empty = false;
599 data.x = x;
600 data.y = y;
601 data.z = z;
602 reinterpret_cast<Data3d*>(m_data)->m_pointset.push_back (data);
603}
604
605void
607{
608 struct Point data;
609 data.empty = true;
610 reinterpret_cast<Data3d*>(m_data)->m_pointset.push_back (data);
611}
612
613// --- Gnuplot3dFunction::Function3d --------------------------------------- //
614
621{
622 // *** Data Variables ***
623
624 std::string m_function;
625
632 Function3d(const std::string& title, const std::string& function);
633
634 virtual std::string GetCommand () const;
635 virtual void PrintExpression (std::ostream &os,
636 bool generateOneOutputFile,
637 unsigned int dataFileDatasetIndex,
638 std::string &dataFileName) const;
639 virtual void PrintDataFile (std::ostream &os, bool generateOneOutputFile) const;
640 virtual bool IsEmpty () const;
641};
642
643Gnuplot3dFunction::Function3d::Function3d(const std::string& title, const std::string& function)
644 : Data (title),
645 m_function (function)
646{
647}
648
649std::string
651{
652 return "splot";
653}
654
655void
657 bool generateOneOutputFile,
658 unsigned int dataFileDatasetIndex,
659 std::string &dataFileName) const
660{
661 os << m_function;
662
663 if (m_title.size ())
664 os << " title \"" << m_title << "\"";
665
666 if (m_extra.size ())
667 os << " " << m_extra;
668}
669
670void
671Gnuplot3dFunction::Function3d::PrintDataFile (std::ostream &os, bool generateOneOutputFile) const
672{
673}
674
675bool
677{
678 return false;
679}
680
681// --- Gnuplot3dFunction --------------------------------------------------- //
682
683Gnuplot3dFunction::Gnuplot3dFunction (const std::string& title, const std::string& function)
684 : GnuplotDataset ( new Function3d (title, function) )
685{
686}
687
688void
689Gnuplot3dFunction::SetFunction (const std::string& function)
690{
691 reinterpret_cast<Function3d*>(m_data)->m_function = function;
692}
693
694// ------------------------------------------------------------------------- //
695
696Gnuplot::Gnuplot (const std::string& outputFilename, const std::string& title)
697 : m_outputFilename (outputFilename),
698 m_terminal ( DetectTerminal (outputFilename) ),
699 m_title (title),
700 m_generateOneOutputFile (false),
701 m_dataFileDatasetIndex (0)
702{
703}
704
705void Gnuplot::SetOutputFilename (const std::string& outputFilename)
706{
707 m_outputFilename = outputFilename;
708}
709
710std::string Gnuplot::DetectTerminal (const std::string& filename)
711{
712 std::string::size_type dotpos = filename.rfind ('.');
713 if (dotpos == std::string::npos) return "";
714
715 if (filename.substr (dotpos) == ".png") {
716 return "png";
717 }
718 else if (filename.substr (dotpos) == ".pdf") {
719 return "pdf";
720 }
721
722 return "";
723}
724
725void
726Gnuplot::SetTerminal (const std::string& terminal)
727{
728 m_terminal = terminal;
729}
730
731void
732Gnuplot::SetTitle (const std::string& title)
733{
734 m_title = title;
735}
736
737void
738Gnuplot::SetLegend (const std::string& xLegend, const std::string& yLegend)
739{
740 m_xLegend = xLegend;
741 m_yLegend = yLegend;
742}
743
744void
745Gnuplot::SetExtra (const std::string& extra)
746{
747 m_extra = extra;
748}
749
750void
751Gnuplot::AppendExtra (const std::string& extra)
752{
753 m_extra += "\n";
754 m_extra += extra;
755}
756
757void
759{
760 m_datasets.push_back (dataset);
761}
762
763void
764Gnuplot::GenerateOutput (std::ostream &os)
765{
766 // If this version of this function is called, it is assumed that a
767 // single output file is being generated.
769
770 // Send the gnuplot metadata to the same stream as the data stream.
771 GenerateOutput (os, os, "");
772}
773
774void
775Gnuplot::GenerateOutput (std::ostream &osControl,
776 std::ostream &osData,
777 std::string dataFileName)
778{
779 if (m_terminal.size ())
780 osControl << "set terminal " << m_terminal << std::endl;
781
782 if (m_outputFilename.size ())
783 osControl << "set output \"" << m_outputFilename << "\"" << std::endl;
784
785 if (m_title.size ())
786 osControl << "set title \"" << m_title << "\"" << std::endl;
787
788 if (m_xLegend.size ())
789 osControl << "set xlabel \"" << m_xLegend << "\"" << std::endl;
790
791 if (m_yLegend.size ())
792 osControl << "set ylabel \"" << m_yLegend << "\"" << std::endl;
793
794 if (m_extra.size ())
795 osControl << m_extra << std::endl;
796
797 if (m_datasets.empty ())
798 return;
799
800 // Determine the GetCommand() values of all datasets included. Check that all
801 // are equal and print the command.
802
803 std::string command = m_datasets.begin ()->m_data->GetCommand ();
804
805 for (Datasets::const_iterator i = m_datasets.begin () + 1;
806 i != m_datasets.end (); ++i)
807 {
808 NS_ASSERT_MSG (command == i->m_data->GetCommand (),
809 "Cannot mix 'plot' and 'splot' GnuplotDatasets.");
810 }
811
812 osControl << command << " ";
813
814 // Print all dataset expressions
815
816 bool isDataEmpty;
817 for (Datasets::const_iterator i = m_datasets.begin (); i != m_datasets.end ();)
818 {
819 // Only print the dataset if it's not empty.
820 isDataEmpty = i->m_data->IsEmpty ();
821 if (!isDataEmpty)
822 {
823 // Print the appropriate expression based on whether we are
824 // generating separate output and date files.
825 i->m_data->PrintExpression (osControl,
828 dataFileName);
829
831 }
832
833 i++;
834 if (i != m_datasets.end () && !isDataEmpty)
835 {
836 osControl << ", ";
837 }
838 }
839 osControl << std::endl;
840
841 // followed by the inline datafile.
842
843 for (Datasets::const_iterator i = m_datasets.begin (); i != m_datasets.end (); i++)
844 {
845 i->m_data->PrintDataFile (osData, m_generateOneOutputFile);
846 }
847}
848
849void
851{
853}
854
855// ------------------------------------------------------------------------- //
856
857GnuplotCollection::GnuplotCollection (const std::string& outputFilename)
858 : m_outputFilename (outputFilename),
859 m_terminal ( Gnuplot::DetectTerminal (outputFilename) )
860{
861}
862
863void
864GnuplotCollection::SetTerminal (const std::string& terminal)
865{
866 m_terminal = terminal;
867}
868
869void
871{
872 m_plots.push_back (plot);
873}
874
875Gnuplot&
877{
878 if (id >= m_plots.size ())
879 throw(std::range_error ("Gnuplot id is out of range"));
880 else
881 return m_plots[id];
882}
883
884void
886{
887 // If this version of this function is called, it is assumed that a
888 // single output file is being generated.
889
890 if (m_terminal.size ())
891 os << "set terminal " << m_terminal << std::endl;
892
893 if (m_outputFilename.size ())
894 os << "set output \"" << m_outputFilename << "\"" << std::endl;
895
896 for (Plots::iterator i = m_plots.begin (); i != m_plots.end (); ++i)
897 {
898 i->GenerateOutput (os);
899 }
900}
901
902void
903GnuplotCollection::GenerateOutput (std::ostream &osControl, std::ostream &osData,
904std::string dataFileName)
905{
906 // If this version of this function is called, it is assumed that
907 // separate output and date files are being generated.
908
909 if (m_terminal.size ())
910 osControl << "set terminal " << m_terminal << std::endl;
911
912 if (m_outputFilename.size ())
913 osControl << "set output \"" << m_outputFilename << "\"" << std::endl;
914
915 for (Plots::iterator i = m_plots.begin (); i != m_plots.end (); ++i)
916 {
917 i->GenerateOutput (osControl, osData, dataFileName);
918 }
919}
920
921// ------------------------------------------------------------------------- //
922
923} // namespace ns3
void AddEmptyLine()
Add an empty line in the data output sequence.
Definition: gnuplot.cc:404
std::vector< struct Point > PointSet
The set of points in the dataset.
Definition: gnuplot.h:226
void SetErrorBars(enum ErrorBars errorBars)
Definition: gnuplot.cc:355
ErrorBars
Whether errorbars should be used for this dataset.
Definition: gnuplot.h:137
static enum Style m_defaultStyle
default plot style
Definition: gnuplot.h:228
void SetStyle(enum Style style)
Definition: gnuplot.cc:344
static void SetDefaultStyle(enum Style style)
Change default style for all newly created objects.
Definition: gnuplot.cc:339
void Add(double x, double y)
Definition: gnuplot.cc:361
Style
The plotting style to use for this dataset.
Definition: gnuplot.h:123
static void SetDefaultErrorBars(enum ErrorBars errorBars)
Change default errorbars style for all newly created objects.
Definition: gnuplot.cc:350
static enum ErrorBars m_defaultErrorBars
default error bars type
Definition: gnuplot.h:229
Gnuplot2dDataset(const std::string &title="Untitled")
Definition: gnuplot.cc:333
void SetFunction(const std::string &function)
Definition: gnuplot.cc:487
Gnuplot2dFunction(const std::string &title="Untitled", const std::string &function="")
Definition: gnuplot.cc:481
void AddEmptyLine()
Add an empty line in the data output sequence.
Definition: gnuplot.cc:606
Gnuplot3dDataset(const std::string &title="Untitled")
Definition: gnuplot.cc:578
static std::string m_defaultStyle
default plot style
Definition: gnuplot.h:324
std::vector< struct Point > PointSet
The set of points in the dataset.
Definition: gnuplot.h:322
void Add(double x, double y, double z)
Definition: gnuplot.cc:595
static void SetDefaultStyle(const std::string &style)
Change default style for all newly created objects.
Definition: gnuplot.cc:584
void SetStyle(const std::string &style)
Definition: gnuplot.cc:589
Gnuplot3dFunction(const std::string &title="Untitled", const std::string &function="")
Definition: gnuplot.cc:683
void SetFunction(const std::string &function)
Definition: gnuplot.cc:689
std::string m_outputFilename
Output file name.
Definition: gnuplot.h:538
GnuplotCollection(const std::string &outputFilename)
Definition: gnuplot.cc:857
void AddPlot(const Gnuplot &plot)
Definition: gnuplot.cc:870
void SetTerminal(const std::string &terminal)
Definition: gnuplot.cc:864
Gnuplot & GetPlot(unsigned int id)
Return a pointer to one of the added plots.
Definition: gnuplot.cc:876
std::string m_terminal
Gnuplot "terminal" to use.
Definition: gnuplot.h:539
Plots m_plots
Plots in the collection.
Definition: gnuplot.h:541
void GenerateOutput(std::ostream &os)
Definition: gnuplot.cc:885
Abstract class to store a plot line to be used by ns3::Gnuplot.
Definition: gnuplot.h:39
GnuplotDataset(const GnuplotDataset &original)
Reference-counting copy constructor.
Definition: gnuplot.cc:115
static void SetDefaultExtra(const std::string &extra)
Change extra formatting style parameters for newly created objects.
Definition: gnuplot.cc:147
GnuplotDataset & operator=(const GnuplotDataset &original)
Reference-counting assignment operator.
Definition: gnuplot.cc:127
struct Data * m_data
Reference counted data object.
Definition: gnuplot.h:107
void SetExtra(const std::string &extra)
Add extra formatting parameters to this dataset.
Definition: gnuplot.cc:152
static std::string m_defaultExtra
Extra gnuplot parameters set on every newly created dataset.
Definition: gnuplot.h:91
void SetTitle(const std::string &title)
Change line title.
Definition: gnuplot.cc:141
~GnuplotDataset()
Reference-counting destructor.
Definition: gnuplot.cc:121
a simple class to generate gnuplot-ready plotting commands from a set of datasets.
Definition: gnuplot.h:372
std::string m_yLegend
Y axis legend.
Definition: gnuplot.h:473
void AddDataset(const GnuplotDataset &dataset)
Definition: gnuplot.cc:758
void SetLegend(const std::string &xLegend, const std::string &yLegend)
Definition: gnuplot.cc:738
void SetTerminal(const std::string &terminal)
Definition: gnuplot.cc:726
std::string m_terminal
Gnuplot "terminal" to use.
Definition: gnuplot.h:467
std::string m_extra
extra parameters for the plot
Definition: gnuplot.h:474
unsigned int m_dataFileDatasetIndex
Data set index to plot.
Definition: gnuplot.h:478
void AppendExtra(const std::string &extra)
Definition: gnuplot.cc:751
Datasets m_datasets
Data sets.
Definition: gnuplot.h:469
void GenerateOutput(std::ostream &os)
Writes gnuplot commands and data values to a single output stream.
Definition: gnuplot.cc:764
std::string m_title
Plot title.
Definition: gnuplot.h:471
void SetDataFileDatasetIndex(unsigned int index)
Sets the current data stream index in the data file.
Definition: gnuplot.cc:850
std::string m_xLegend
X axis legend.
Definition: gnuplot.h:472
std::string m_outputFilename
Output file name.
Definition: gnuplot.h:466
Gnuplot(const std::string &outputFilename="", const std::string &title="")
Definition: gnuplot.cc:696
void SetExtra(const std::string &extra)
Definition: gnuplot.cc:745
void SetTitle(const std::string &title)
Definition: gnuplot.cc:732
void SetOutputFilename(const std::string &outputFilename)
Definition: gnuplot.cc:705
bool m_generateOneOutputFile
true if only one plot will be generated
Definition: gnuplot.h:476
static std::string DetectTerminal(const std::string &filename)
Crude attempt to auto-detect the correct terminal setting by inspecting the filename's extension.
Definition: gnuplot.cc:710
#define NS_ASSERT(condition)
At runtime, in debugging builds, if this condition is not true, the program prints the source file,...
Definition: assert.h:67
#define NS_ASSERT_MSG(condition, message)
At runtime, in debugging builds, if this condition is not true, the program prints the message to out...
Definition: assert.h:88
Every class exported by the ns3 library is enclosed in the ns3 namespace.
list x
Random number samples.
uint8_t data[writeSize]
Structure storing the data to for a 2D plot.
Definition: gnuplot.cc:165
virtual void PrintExpression(std::ostream &os, bool generateOneOutputFile, unsigned int dataFileDatasetIndex, std::string &dataFileName) const
Prints the plot description used as argument to (s)plot.
Definition: gnuplot.cc:202
enum ErrorBars m_errorBars
Whether errorbars should be used for this dataset.
Definition: gnuplot.cc:169
virtual std::string GetCommand() const
Returns the plot type ("plot" or "splot").
Definition: gnuplot.cc:196
virtual void PrintDataFile(std::ostream &os, bool generateOneOutputFile) const
Print the inline data file contents trailing the plot command.
Definition: gnuplot.cc:281
PointSet m_pointset
The set of points in this data set.
Definition: gnuplot.cc:171
virtual bool IsEmpty() const
Checks to see if this GnuplotDataset is empty.
Definition: gnuplot.cc:321
Data2d(const std::string &title)
Initializes with the values from m_defaultStyle and m_defaultErrorBars.
Definition: gnuplot.cc:188
enum Style m_style
The plotting style to use for this dataset.
Definition: gnuplot.cc:168
A point in a 2D plot.
Definition: gnuplot.h:217
Structure storing the function to be used for a 2D plot.
Definition: gnuplot.cc:419
virtual void PrintDataFile(std::ostream &os, bool generateOneOutputFile) const
Print the inline data file contents trailing the plot command.
Definition: gnuplot.cc:469
Function2d(const std::string &title, const std::string &function)
Initializes with the function and title.
Definition: gnuplot.cc:441
virtual void PrintExpression(std::ostream &os, bool generateOneOutputFile, unsigned int dataFileDatasetIndex, std::string &dataFileName) const
Prints the plot description used as argument to (s)plot.
Definition: gnuplot.cc:454
std::string m_function
Function to use.
Definition: gnuplot.cc:422
virtual std::string GetCommand() const
Returns the plot type ("plot" or "splot").
Definition: gnuplot.cc:448
virtual bool IsEmpty() const
Checks to see if this GnuplotDataset is empty.
Definition: gnuplot.cc:474
Structure storing the data for a 3D plot.
Definition: gnuplot.cc:500
virtual void PrintExpression(std::ostream &os, bool generateOneOutputFile, unsigned int dataFileDatasetIndex, std::string &dataFileName) const
Prints the plot description used as argument to (s)plot.
Definition: gnuplot.cc:535
virtual std::string GetCommand() const
Returns the plot type ("plot" or "splot").
Definition: gnuplot.cc:529
virtual bool IsEmpty() const
Checks to see if this GnuplotDataset is empty.
Definition: gnuplot.cc:569
std::string m_style
The plotting style to use for this dataset.
Definition: gnuplot.cc:503
PointSet m_pointset
The set of points in this data set.
Definition: gnuplot.cc:505
virtual void PrintDataFile(std::ostream &os, bool generateOneOutputFile) const
Print the inline data file contents trailing the plot command.
Definition: gnuplot.cc:553
Data3d(const std::string &title)
Initializes with value from m_defaultStyle.
Definition: gnuplot.cc:522
A point in a 3D plot.
Definition: gnuplot.h:314
Structure storing the function to be used for a 3D plot.
Definition: gnuplot.cc:621
std::string m_function
Function to use.
Definition: gnuplot.cc:624
virtual void PrintDataFile(std::ostream &os, bool generateOneOutputFile) const
Print the inline data file contents trailing the plot command.
Definition: gnuplot.cc:671
virtual void PrintExpression(std::ostream &os, bool generateOneOutputFile, unsigned int dataFileDatasetIndex, std::string &dataFileName) const
Prints the plot description used as argument to (s)plot.
Definition: gnuplot.cc:656
Function3d(const std::string &title, const std::string &function)
Initializes with the function and title.
Definition: gnuplot.cc:643
virtual bool IsEmpty() const
Checks to see if this GnuplotDataset is empty.
Definition: gnuplot.cc:676
virtual std::string GetCommand() const
Returns the plot type ("plot" or "splot").
Definition: gnuplot.cc:650
Structure storing the data to plot.
Definition: gnuplot.cc:37
unsigned int m_references
ref/unref counter for garbage collection
Definition: gnuplot.cc:40
std::string m_extra
Extra parameters for the plot.
Definition: gnuplot.cc:43
virtual void PrintExpression(std::ostream &os, bool generateOneOutputFile, unsigned int dataFileDatasetIndex, std::string &dataFileName) const =0
Prints the plot description used as argument to (s)plot.
virtual ~Data()
Required.
Definition: gnuplot.cc:102
virtual void PrintDataFile(std::ostream &os, bool generateOneOutputFile) const =0
Print the inline data file contents trailing the plot command.
virtual bool IsEmpty() const =0
Checks to see if this GnuplotDataset is empty.
Data(const std::string &title)
Initializes the reference counter to 1 and sets m_title and m_extra.
Definition: gnuplot.cc:95
std::string m_title
Dataset title.
Definition: gnuplot.cc:42
virtual std::string GetCommand() const =0
Returns the plot type ("plot" or "splot").