I am plotting a 3d surface with gnuplot “splot” function. The data is written in (x,y,z) format in 3 columns in a text file. When I plot the data from the file, splot connects the endpoints of the data. The surface itself is correct, but there is an additional unwanted set of parallel lines (forming an xy plane) at the bottom of the surface. So for each x, it plots a function decaying to zero symmetrically, but then +\infty and -\infty are connected together as well! That makes something like an unwanted x-axis below the graph.
I tried to set off boundaries to zero, playing with data format, etc. No luck!
Your problem is that your data isn’t in ‘grid data’ format. Gnuplot sees the data and plots it as lines instead of plotting it as a surface. Unfortunately, I don’t know matlab, but here’s some pseudo-code which should work (although may not be the most efficient way to write the data):
Of course, if your grids can be expressed as 1D arrays (instead of 2D as above), you can just do the following (with appropriate loops):
Alternatively, you can use
dgrid3din gnuplot.dgrid3dinterpolates non-grid data into grid data. By default, it interpolates to a 10×10 grid which as you noted is pretty coarse. You can increase this byset dgrid3d NX,NYwhereNXandNYare the number of points on the x and y axes respectively.Finally, if you don’t want to mess with your datafile, you might want to consider using the following
awkscript from the gnuplot FAQ (section 3.9):Now to plot your surface: