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

Function plot3

src/plot.cxx:1395–1490  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1393}
1394
1395void plot3(const MatrixXd& xa, const MatrixXd& ya, const MatrixXd& za, const string& title, const char* xlabel, const char* ylabel, const char* zlabel, const char* terminal, const char* output, const char* view)
1396{
1397 // This function creates 3d plots given the co-ordinate values (x,y) and the height vector z.
1398
1399 MatrixXd x = xa;
1400 MatrixXd y = ya;
1401 MatrixXd z = za;
1402
1403 FILE *gscript, *datafile;
1404
1405 double range_min = 0.001;
1406
1407 int i,j;
1408
1409 MatrixXd X, Y, Z;
1410
1411 if (x.rows()>1 && x.cols()>1) error_message("plot3(): MatrixXd object x must be a vector");
1412
1413 if (y.rows()>1 && y.cols()>1) error_message("plot3(): MatrixXd object y must be a vector");
1414
1415 if (z.rows()>1 && z.cols()>1) error_message("plot3(): MatrixXd object z must be a vector");
1416
1417
1418 X = stack_columns(x);
1419
1420
1421 Y = stack_columns(y);
1422
1423
1424 Z = stack_columns(z);
1425
1426 if ( length(X) != length(Y) || length(x)!=length(Z) ) {
1427 error_message("plot3(): inconsistent array lengths");
1428 }
1429
1430 int nz = MIN( z.rows(), z.cols() );
1431
1432 int pos = 0;
1433
1434 double MinZ = Min(z);
1435
1436 double MaxZ = Max(z);
1437
1438 if (fabs(MinZ)<range_min && fabs(MaxZ)<range_min )
1439 {
1440 MinZ = -range_min;
1441 MaxZ = range_min;
1442 }
1443
1444 datafile = fopen("XYZ.dat","w");
1445
1446 if (datafile==NULL) error_message("surf(): error creating gnuplot data file");
1447
1448 for (i=0; i<length(X); i++) {
1449
1450 fprintf(datafile,"%f %f %f\n",X(i),Y(i), Z(i) );
1451
1452 }

Callers 4

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

Calls 7

error_messageFunction · 0.85
stack_columnsFunction · 0.85
lengthFunction · 0.85
MinFunction · 0.85
MaxFunction · 0.85
rowsMethod · 0.45
colsMethod · 0.45

Tested by

no test coverage detected