MCPcopy Create free account
hub / github.com/PSOPT/psopt / plot

Function plot

src/plot.cxx:68–170  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

66
67
68void plot(const MatrixXd& xa, const MatrixXd& ya, const string& title, const char* xlabel, const char* ylabel, const char* legend, const char* terminal, const char* output)
69{
70
71 MatrixXd x = xa;
72
73 MatrixXd y = ya;
74
75 FILE *gscript;
76
77 double range_min = 0.001;
78
79 char legend_i[100];
80
81 MatrixXd XY;
82
83 if ( y.rows() < y.cols() )
84 {
85
86
87 x = x.transpose().eval();
88 y = y.transpose().eval();
89 XY.resize(x.rows(), x.cols()+y.cols());
90 XY << x, y;
91 }
92 else {
93
94 XY.resize(x.rows(), x.cols()+y.cols());
95 XY << x, y;
96 }
97
98 int ny = MIN( y.rows(), y.cols() );
99
100 int pos = 0;
101
102 double MinY = Min(y) - 0.05*fabs(Min(y));
103
104 double MaxY = Max(y) + 0.05*fabs(Min(y));
105
106 if (fabs(MinY)<range_min && fabs(MaxY)<range_min )
107 {
108 MinY = -range_min;
109 MaxY = range_min;
110 }
111
112 if (fabs(MinY-MaxY)< range_min) MaxY=MinY+range_min;
113
114 Save(XY, "XY.dat");
115
116 gscript = fopen("gnuplot.scp","w");
117
118 if (terminal!=NULL) fprintf(gscript,"\nset terminal %s", terminal);
119
120 if (output!=NULL) fprintf(gscript,"\nset output \"%s\"", output);
121
122 fprintf(gscript,"\nset style data lines");
123
124 fprintf(gscript,"\nset multiplot");
125

Callers 15

mainFunction · 0.85
mainFunction · 0.85
mainFunction · 0.85
mainFunction · 0.85
mainFunction · 0.85
mainFunction · 0.85
mainFunction · 0.85
mainFunction · 0.85
mainFunction · 0.85
mainFunction · 0.85
mainFunction · 0.85
mainFunction · 0.85

Calls 6

MinFunction · 0.85
MaxFunction · 0.85
SaveFunction · 0.85
rowsMethod · 0.45
colsMethod · 0.45
resizeMethod · 0.45

Tested by

no test coverage detected