add legend support to gnuplot output
authorMathieu Lacage <mathieu.lacage@sophia.inria.fr>
Wed, 12 Dec 2007 09:33:22 +0100
changeset 2267 87dd46db981d
parent 2266 d0e656113f71
child 2268 0e57ac711220
add legend support to gnuplot output
src/contrib/gnuplot.cc
src/contrib/gnuplot.h
--- a/src/contrib/gnuplot.cc	Tue Dec 11 17:53:54 2007 +0100
+++ b/src/contrib/gnuplot.cc	Wed Dec 12 09:33:22 2007 +0100
@@ -75,6 +75,13 @@
 }
 
 void 
+Gnuplot::SetLegend (std::string xLegend, std::string yLegend)
+{
+  m_xLegend = xLegend;
+  m_yLegend = yLegend;
+}
+
+void 
 Gnuplot::AddDataset (const GnuplotDataset &dataset)
 {
   m_datasets.push_back (new GnuplotDataset (dataset));
@@ -85,6 +92,8 @@
 {
   os << "set terminal png" << std::endl;
   os << "set output '" << m_pngFilename << "'" << std::endl;
+  os << "set xlabel '" << m_xLegend << "'" << std::endl;
+  os << "set ylabel '" << m_yLegend << "'" << std::endl;
   os << "plot ";
   for (Datasets::const_iterator i = m_datasets.begin (); i != m_datasets.end ();)
     {
--- a/src/contrib/gnuplot.h	Tue Dec 11 17:53:54 2007 +0100
+++ b/src/contrib/gnuplot.h	Wed Dec 12 09:33:22 2007 +0100
@@ -73,12 +73,16 @@
   Gnuplot (std::string pngFilename);
   ~Gnuplot ();
 
+  void SetLegend (std::string xLegend, std::string yLegend);
+
   void AddDataset (const GnuplotDataset &dataset);
 
   void GenerateOutput (std::ostream &os);
 private:
   typedef std::vector<GnuplotDataset *> Datasets;
   Datasets m_datasets;
+  std::string m_xLegend;
+  std::string m_yLegend;
   std::string m_pngFilename;
 };