| 66 | |
| 67 | |
| 68 | void 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 |
no test coverage detected