-
Notifications
You must be signed in to change notification settings - Fork 12
Description
Hey,
I'm trying to make a surface plot of a 2D array, where its indexes would be the x and y axes and the values of the array would be z = f ( x, y ), but I'm failing miserably, even with the documentation, and examples on PLplot site written in C++.
How hard would it be to create a plot like this and what do I need?
I was trying to tinker around with plot3d method and I've checked out your C# example - I can set up the XYZ environment, but I can't create the plot itself:

Exiting my program causes this error to show up in my VS:
*** PLPLOT ERROR, ABORTING OPERATION *** plot3dcl: Bad option, aborting operation
Here's "my" code so far:
`var pl = new PLStream();
//use SVG backend and write to SineWaves.svg in current directory
pl.sdev("pngcairo");
pl.sfnam("SineWaves.png");
// use white background with black foreground
pl.spal0("cmap0_alternate.pal");
// Initialize plplot
pl.init();
double[] xIndexes, yIndexes;
xIndexes = new double[temp.width];
yIndexes = new double[temp.height];
for (int i = 0; i < temp.width; i++)
xIndexes[i] = i;
for (int i = 0; i < temp.height; i++)
yIndexes[i] = i;
//Mesh opt = new Mesh();
double[,] CDF = new double[surface.width, surface.height];
for (int i = 0; i < surface.width; i++)
for (int j = 0; j < surface.height; j++)
CDF[i, j] = CumulativeDistributionFunction[i, j].result;//This is the array I'm trying to make a plot of
Mesh opt = new Mesh(); // line with possible issue
pl.adv(0);
pl.col0(1);
pl.vpor(0.0, 1.0, 0.0, 0.9);
pl.wind(-1.0, 1.0, -1.0, 1.0);
pl.w3d(1.0, 1.0, 1.0, 0, surface.width, 0, surface.height, 0, 1,60, 30);
pl.box3("bnstu", "x axis", 0.0, 0, "bnstu", "y axis", 0.0, 0, "bcdmnstuv", "z axis", 0.0, 4);
pl.col0(2);
pl.scmap1n(256);
pl.plot3d(xIndexes, yIndexes, CDF, opt, true); //line with possible issue
pl.col0(3);
pl.mtex("t", 1.0, 0.5, 0.5, "Title");
// end page (writes output to disk)
pl.eop();
// output version
pl.gver(out var verText);
Console.WriteLine("PLplot version " + verText);`
Now about the possible issue - in the C and C++ implementations of example 11 that I've looked at (http://plplot.org/examples.php?demo=11&lbind=C%2B%2B), the plot3d method takes the opt argument as an int:
static const int opt[]; ... pls->plot3d( x, y, z, XPTS, YPTS, **opt[k]** | MAG_COLOR, true );
While in C# plot3d takes opt argument as a Mesh:
public void plot3d(double[] x, double[] y, double[,] z, Mesh opt, bool side);
As a result I have no idea what am I supposed to pass there, not to mention that I can't find the definitions of DRAW_LINEX, DRAW_LINEY and DRAW_LINEXY, or what they are anyway. Is opt supposed to be a Mesh?
So in the end - what am I doing wrong, what do I need to do to make a 3D plot of a 2D array, and could you maybe translate the example 11 to C#?