-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgnuplot.cpp
More file actions
119 lines (117 loc) · 4.72 KB
/
Copy pathgnuplot.cpp
File metadata and controls
119 lines (117 loc) · 4.72 KB
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
#include"gnuplot.h"
GNUPLOT::GNUPLOT(){path="";}
GNUPLOT::~GNUPLOT()
{}
void GNUPLOT::plot3D(string data,string gnuplot_commands,string operation,string title_op,string *extracommands,
int extra_commands,char var1,char var2,double var1_r[2],double var2_r[2])
{
int i;
quotation="\"";
ofstream commands;
//PM3D
commands.open((gnuplot_commands+".plot3").c_str());
commands<<"set term postscrip eps color enhanced "+quotation+"Helvetica"+quotation+" 13"<<endl;
commands<<"set output "+quotation+operation+".eps"+quotation<<endl;
commands<<"set title "+quotation+title_op+" vs ("<<var1<<","<<var2<<",0)"+quotation+" font "+quotation+"Helvetica,18"+quotation<<endl;
commands<<"set xlabel "+quotation<<var1<<quotation+" font "+quotation+"Helvetica,18"+quotation<<endl;
commands<<"set ylabel "+quotation<<var2<<quotation+" font "+quotation+"Helvetica,18"+quotation<<endl;
commands<<"set zlabel "+quotation+title_op+quotation+" font "+quotation+"Helvetica,18"+quotation+"offset 2,11"<<endl;
commands<<"set xr ["<<var1_r[0]<<":"<<var1_r[1]<<"]"<<endl;
commands<<"set yr ["<<var2_r[0]<<":"<<var2_r[1]<<"]"<<endl;
commands<<"set format z "+quotation+"%.2e"+quotation<<endl;
commands<<"set grid"<<endl;
commands<<"set contour base"<<endl;
commands<<"set ticslevel 0"<<endl;
commands<<"set key spacing 1"<<endl;
commands<<"set isosamples 40"<<endl;
commands<<"set cntrparam levels 10"<<endl;
commands<<"unset clabel"<<endl;
commands<<"set style line 1 lt rgb "+quotation+"black"+quotation+"lw 1.5 pt 4"<<endl;
if(extra_commands!=0)
{
for(i=0;i<extra_commands;i++)
{
commands<<extracommands[i]<<endl;
}
}
commands<<"splot "+quotation+data+quotation+" u 1:2:3 w pm3d ls 1 title "+quotation+" "+quotation<<endl;
commands.close();
if(path!="")
{
system((path+" <"+gnuplot_commands+".plot3").c_str());
}
else
{
system(("gnuplot <"+gnuplot_commands+".plot3").c_str());
}
//PM3D MAP
commands.open((gnuplot_commands+"_map.plot3").c_str());
commands<<"set term postscrip eps color enhanced "+quotation+"Helvetica"+quotation+" 13"<<endl;
commands<<"set output "+quotation+operation+"_map.eps"+quotation<<endl;
commands<<"set title "+quotation+title_op+" vs ("<<var1<<","<<var2<<",0)"+quotation+" font "+quotation+"Helvetica,20"+quotation<<endl;
commands<<"set xlabel "+quotation<<var1<<quotation+" font "+quotation+"Helvetica,20"+quotation<<endl;
commands<<"set label 1 "+quotation<<var2<<quotation+" font "+quotation+"Helvetica,20"+quotation+" at graph -0.1, graph 0.5"<<endl;
commands<<"set zlabel "+quotation+title_op+quotation+" font "+quotation+"Helvetica,20"+quotation<<endl;
commands<<"set xr ["<<var1_r[0]<<":"<<var1_r[1]<<"]"<<endl;
commands<<"set yr ["<<var2_r[0]<<":"<<var2_r[1]<<"]"<<endl;
commands<<"set grid"<<endl;
commands<<"set contour base"<<endl;
commands<<"set pm3d map"<<endl;
commands<<"set key spacing 1"<<endl;
commands<<"set palette rgbformulae 33,13,10"<<endl;
commands<<"set cntrparam levels 10"<<endl;
commands<<"unset clabel"<<endl;
commands<<"set style line 1 lt rgb "+quotation+"black"+quotation+"lw 1.5 pt 4"<<endl;
if(extra_commands!=0)
{
for(i=0;i<extra_commands;i++)
{
commands<<extracommands[i]<<endl;
}
}
commands<<"splot "+quotation+data+quotation+" u 1:2:3 w pm3d ls 1 title "+quotation+" "+quotation<<endl;
commands.close();
if(path!="")
{
system((path+" <"+gnuplot_commands+"_map.plot3").c_str());
}
else
{
system(("gnuplot <"+gnuplot_commands+"_map.plot3").c_str());
}
}
void GNUPLOT::plot2D(string data,string gnuplot_commands,string operation,string title_op,string *extracommands,
int extra_commands,char var1,double var1_r[2])
{
int i;
quotation="\"";
ofstream commands;
//2D Plot
commands.open((gnuplot_commands+".plot2").c_str());
commands<<"set term postscrip eps color enhanced "+quotation+"Helvetica"+quotation+" 13"<<endl;
commands<<"set output "+quotation+operation+".eps"+quotation<<endl;
commands<<"set title "+quotation+title_op+" vs "<<var1<<" "<<quotation+" font "+quotation+"Helvetica,18"+quotation<<endl;
commands<<"set xlabel "+quotation<<var1<<quotation+" font "+quotation+"Helvetica,18"+quotation<<endl;
commands<<"set label 1 "+quotation+title_op+quotation+" font "+quotation+"Helvetica,18"+quotation+" at graph -0.05, graph 1.06"<<endl;
commands<<"set xr ["<<var1_r[0]<<":"<<var1_r[1]<<"]"<<endl;
commands<<"set grid"<<endl;
commands<<"set format y "+quotation+"%.2e"+quotation<<endl;
if(extra_commands!=0)
{
for(i=0;i<extra_commands;i++)
{
commands<<extracommands[i]<<endl;
}
}
commands<<"plot "+quotation+data+quotation+" u 1:2 with linespoints title "+quotation+title_op+quotation<<endl;
commands.close();
if(path!="")
{
system((path+" <"+gnuplot_commands+".plot2").c_str());
}
else
{
system(("gnuplot <"+gnuplot_commands+".plot2").c_str());
}
commands.close();
}