1
votes

My data file is a 9800x128 matrix of floating point values, and I'm having trouble plotting a surface graph, that should look similar to MATLABs surf() plot.

Using:

splot '/directory/data.txt' every ::1:1 matrix with lines

works fine, but everything is in one color which makes it impossible to see what's going on. The color palette that I've imported is:

set palette defined (0 0 0 0.5, 1 0 0 1, 2 0 0.5 1, 3 0 1 1, 4 0.5 1 0.5, 5 1 1 0, 6 1 0.5 0, 7 1 0 0, 8 0.5 0 0)

Which is similar to the default one used in MATLAB. Drawing just a 2D contour using this palette:

plot '/directory/data.txt' matrix notitle with image

works just fine as well, it's as soon as I try to marry the color map with a surface plots, as follows:

splot '/directory/data.txt' every ::1:1 matrix with image

I get the following warning message and I'm left with an empty plot.

warning: Number of pixels cannot be factored into integers matching grid. N = 1244473  K = 762
1

1 Answers

1
votes

If your data is saved as matrix format, i.e. arranged as

z00 z10 z20 z30 ...
z01 z11 z21 z31 ...
z02 z12 z22 z32 ...
z03 z13 z23 z33 ...
...

then you can plot you data with

set palette defined (0 0 0 0.5, 1 0 0 1, 2 0 0.5 1, 3 0 1 1, 4 0.5 1 0.5, 5 1 1 0, 6 1 0.5 0, 7 1 0 0, 8 0.5 0 0)
splot 'data.txt' matrix with pm3d