add legend support to gnuplot output

This commit is contained in:
Mathieu Lacage
2007-12-12 09:33:22 +01:00
parent 457d07a50f
commit 01d7a64670
2 changed files with 13 additions and 0 deletions

View File

@@ -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 ();)
{

View File

@@ -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<GnuplotDataset *> Datasets;
Datasets m_datasets;
std::string m_xLegend;
std::string m_yLegend;
std::string m_pngFilename;
};