a Code for the Combination of Indirect and Direct Constraints on High Energy Physics Models Logo
TwoDimensionalDataPlotter.hpp
Go to the documentation of this file.
1/*
2 * TwoDimensionalDataPlotter.hpp
3 *
4 * Created on: Jan 8, 2012
5 * Author: Ben O'Leary (benjamin.oleary@gmail.com)
6 *
7 * This file is part of BOLlib, released under the
8 * GNU General Public License. Please see the accompanying
9 * README.BOLlib.txt file for a full list of files, brief documentation
10 * on how to use these classes, and further details on the license.
11 */
12
13#ifndef TWODIMENSIONALDATAPLOTTER_HPP_
14#define TWODIMENSIONALDATAPLOTTER_HPP_
15
16#include <iostream>
17#include <fstream>
18#include <string>
19#include "VectorlikeArray.hpp"
21
22namespace BOL
23{
24 // this class is used to make plots of data using Gnuplot.
26 {
27 public:
28 typedef std::pair< double, double > DoublePair;
29 typedef std::pair< std::string, std::string > StringPair;
30 typedef std::vector< DoublePair > DoublePairVector;
31 typedef
32 std::pair< DoublePairVector, std::string > DoublePairVectorWithString;
33 typedef
34 std::pair< DoublePairVector, StringPair > DoublePairVectorWithStringPair;
35 typedef
36 std::vector< DoublePairVectorWithStringPair > PlotDataVector;
37
38 TwoDimensionalDataPlotter( std::string const& pathToGnuplotExecutable,
39 std::string const& plotFileName);
41
42 void
43 addPoint( double const xValue,
44 double const yValue );
45 void
46 plotData( std::string const legendString = "",
47 std::string const xAxisLabel = "",
48 std::string const yAxisLabel = "" );
49 void
50 plotData( std::vector< DoublePairVectorWithString > const& dataAndColors,
51 std::string const xAxisLabel = "",
52 std::string const yAxisLabel = "" );
53 void
54 plotData( PlotDataVector const& dataAndColorsAndLabels,
55 std::string const xAxisLabel = "",
56 std::string const yAxisLabel = "" );
57 void
58 clearEntries( std::string plotFileName );
59
60
61 protected:
62 std::string plotFileName;
63 std::string const gnuplotDataFileName;
64 std::string const gnuplotCommandFileName;
65 int const patienceTicks;
67 std::ofstream outputStream;
69 };
70
71
72
73 inline void
75 double const yValue )
76 {
77 dataPoints.newEnd().first = xValue;
78 dataPoints.getBack().second = yValue;
79 }
80
81 inline void
82 TwoDimensionalDataPlotter::clearEntries( std::string plotFileName )
83 {
84 this->plotFileName.assign( plotFileName );
85 dataPoints.setSize( 0 );
86 }
87
88}
89
90#endif /* TWODIMENSIONALDATAPLOTTER_HPP_ */
std::pair< std::string, std::string > StringPair
void clearEntries(std::string plotFileName)
std::pair< DoublePairVector, std::string > DoublePairVectorWithString
std::vector< DoublePair > DoublePairVector
std::vector< DoublePairVectorWithStringPair > PlotDataVector
std::pair< DoublePairVector, StringPair > DoublePairVectorWithStringPair
std::pair< double, double > DoublePair
void plotData(std::string const legendString="", std::string const xAxisLabel="", std::string const yAxisLabel="")
WaitingOnSubprocessExecutor gnuplotExecutor
VectorlikeArray< std::pair< double, double > > dataPoints
void addPoint(double const xValue, double const yValue)
TwoDimensionalDataPlotter(std::string const &pathToGnuplotExecutable, std::string const &plotFileName)