From 01d7a64670d7ec15e8fea77bc6ef4dfc88130e46 Mon Sep 17 00:00:00 2001 From: Mathieu Lacage Date: Wed, 12 Dec 2007 09:33:22 +0100 Subject: [PATCH] add legend support to gnuplot output --- src/contrib/gnuplot.cc | 9 +++++++++ src/contrib/gnuplot.h | 4 ++++ 2 files changed, 13 insertions(+) diff --git a/src/contrib/gnuplot.cc b/src/contrib/gnuplot.cc index 1bbb51f5c..945a78ab7 100644 --- a/src/contrib/gnuplot.cc +++ b/src/contrib/gnuplot.cc @@ -74,6 +74,13 @@ Gnuplot::~Gnuplot () m_datasets.clear (); } +void +Gnuplot::SetLegend (std::string xLegend, std::string yLegend) +{ + m_xLegend = xLegend; + m_yLegend = yLegend; +} + void Gnuplot::AddDataset (const GnuplotDataset &dataset) { @@ -85,6 +92,8 @@ Gnuplot::GenerateOutput (std::ostream &os) { 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 ();) { diff --git a/src/contrib/gnuplot.h b/src/contrib/gnuplot.h index 9558a79d7..19e1632c9 100644 --- a/src/contrib/gnuplot.h +++ b/src/contrib/gnuplot.h @@ -73,12 +73,16 @@ public: 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 Datasets; Datasets m_datasets; + std::string m_xLegend; + std::string m_yLegend; std::string m_pngFilename; };