-
Notifications
You must be signed in to change notification settings - Fork 0
/
gnuplot_i.hpp
executable file
·143 lines (119 loc) · 3.96 KB
/
gnuplot_i.hpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
/**
* A C++ interface to gnuplot.
*
* @brief This is a direct translation from the C interface
* written by N. Devillard (which is available from
* http://ndevilla.free.fr/gnuplot/). As in the C interface
* this uses pipes and so wont run on a system that doesn't
* have POSIX pipe support.
*
* Rajarshi Guha
*
*
* Improvements and optimizations have been added by:
* David Cleres & Nicolas Lesimple
*
* 07/03/03
*
* \file gnuplot_i.cpp
*
*/
#ifndef _GNUPLOT_PIPES_H_
#define _GNUPLOT_PIPES_H_
#include <stdarg.h>
#include <unistd.h>
#include <cstdlib>
#include <cstdio>
#include <cstring>
#include <string>
#include <iostream>
#include <fstream>
#include <sstream>
#include <list>
#include <vector>
#include <stdexcept>
#define GP_MAX_TMP_FILES 64
#define GP_TMP_NAME_SIZE 512
#define GP_CMD_SIZE 1024
#define GP_TITLE_SIZE 80
using namespace std;
///@class
class GnuplotException : public runtime_error
{
public:
GnuplotException(const string &msg) : runtime_error(msg){}
};
///@class
class Gnuplot
{
private:
FILE *gnucmd;
string pstyle;
vector<string> to_delete;
int nplots;
bool get_program_path(const string);
bool valid;
public:
///Default Constructor
Gnuplot();
/// set a style during construction
Gnuplot(const string &);
/// @brief The equivilant of gnuplot_plot_once, the two forms
/// allow you to plot either (x,y) pairs or just a single
/// vector at one go
///@param title is the title of the graph
///@param style is the style of the graph
///@param xlabel is the name of the x axis of the graph
///@param ylabel is the name of the y axis of the graph
Gnuplot(const string &, // title
const string &, // style
const string &, // xlabel
const string &, // ylabel
vector<double> const& , vector<double> const&);
/// @brief The equivilant of gnuplot_plot_once, the two forms
/// allow you to plot either (x,y) pairs or just a single
/// vector at one go
///@param title is the title of the graph
///@param style is the style of the graph
///@param xlabel is the name of the x axis of the graph
///@param ylabel is the name of the y axis of the graph
Gnuplot(const string &, //title
const string &, //style
const string &, //xlabel
const string &, //ylabel
vector<double> const&);
///@brief destructor
~Gnuplot();
/// @brief send a command to gnuplot
void cmd(const char*, ...);
/// @brief set line style
void set_style(const string &);
/// @brief set y axis labels
void set_ylabel(const string &);
/// @brief set x axis labels
void set_xlabel(const string &);
/// @brief plot a single vector
void plot_x(vector<double>,
const string & // title
);
/// @brief plot x,y pairs
void plot_xy(vector<double>, vector<double>,
const string & // title
);
/// @brief plot an equation of the form: y = ax + b. You supply a and b
void plot_slope(
double, // a
double, // b
const string & // title
);
/// @brief plot an equation supplied as a string
void plot_equation(
const string &, // equation
const string & // title
);
/// @brief if multiple plots are present it will clear the plot area
void reset_plot(void);
/// @brief assess the validity
bool is_valid(void);
};
#endif