I can't plot correctly the data of a file using pm3d and dgrid3d. The result obtained does not respect the desired grid and colours.
To understand what was going wrong, I created the following simple data file with the three columns, x, y, z where there are 6 different values for the x, 3 for the y, and the surface value in the z.
test.dat:
0 1 1
0 2 0
0 3 0
1 1 1
1 2 0.25
1 3 0
2 1 1
2 2 0.5
2 3 0
3 1 0
3 2 0.5
3 3 0
4 1 0
4 2 0.25
4 3 1
5 1 0
5 2 0
5 3 1
My code:
set autoscale
set ytics 1
set xtics 1
set ztics 0.1
set view map
set contour base
set palette rgbformulae 22,13,10
set colorbox
set dgrid3d 3,6
set pm3d interpolate 1,1
splot 'test.dat' using 1:2:3 with pm3d notitle
I can't get the number of rows and columns of the grid to be respected with dgrid3d.
With dgrid3d 3,6, I get 2 rows and 5 columns instead of 3 and 6. Also, if I modify the interpolation or other parameters, the colours are not correct. I have tried inverting the values, with dgrid 6,3 or interchanging the columns x-y but it does not work. I have tried also eliminate line dgrid3d but it does not plot anything, it remains blank.
Finally, I have tried to make a “test” plotting only points with line:
splot 'test2.dat' using 1:2:3 with points pt 7 palette notitle
and then it plots correctly!
Thanks for providing a minimized example with script and data. However, minimizing sometimes might oversimplify things. My current understanding is that you have some data in a regular matrix in x,y,z
format. So, depending on how your real data looks like and what you really want to do, I don't see why you would need splot
and dgrid3d
.
If there are no other constraints, probably the simplest way is the following:
Data: SO79388556.dat
0 1 1
0 2 0
0 3 0
1 1 1
1 2 0.25
1 3 0
2 1 1
2 2 0.5
2 3 0
3 1 0
3 2 0.5
3 3 0
4 1 0
4 2 0.25
4 3 1
5 1 0
5 2 0
5 3 1
Script:
### plot x,y,z data with image
reset session
FILE = "SO79388556.dat"
set size ratio -1
set xrange noextend
set yrange noextend
set grid mx,my front lt -1
set ytics 1 scale 0,1
set mxtics 2
set mytics 2
set tics out
set key noautotitle
set palette rgb 22,13,10
plot FILE u 1:2:3 w image
### end of script
Result: