jaywalker
jaywalker

Reputation: 1146

Gnuplot - 3D Surface Graph

I am trying to create a 3D surface plot which looks like this: enter image description here

Instead of plotting the equation, I am trying to plot my own set of data contained in the data.tsv file in the recommended grid format.

8417    5128    4661
7284    4940    3373
5220    3597    4088

For clarity, The XYZ representation of the above data is:

rec/s   mb/s    latency
640000  1024    5220
640000  2048    3597
640000  4096    4088
320000  1024    7284
320000  2048    4940
320000  4096    3373
160000  1024    8417
160000  2048    5128
160000  4096    4661 

The gnuplot script that I am using to get the desired output is:

set term postscript eps enhanced color 
set output '|ps2pdf - outputfile.pdf'
set bar 1.000000 front
set style circle radius graph 0.02, first 0.00000, 0.00000 
set style ellipse size graph 0.05, 0.03, first 0.00000 angle 0 units xy
set style textbox transparent margins  1.0,  1.0 border
unset logscale
set samples 51, 51
set isosamples 21, 21
set style data lines
unset paxis 1 tics
unset paxis 2 tics
unset paxis 3 tics
unset paxis 4 tics
unset paxis 5 tics
unset paxis 6 tics
unset paxis 7 tics
set title "3D gnuplot demo" 
set xlabel "X axis" 
set xlabel  offset character -3, -2, 0 font "" textcolor lt -1 norotate
set xrange [ 160000 : 640000 ] noreverse nowriteback
set ylabel "Y axis" 
set ylabel  offset character 3, -2, 0 font "" textcolor lt -1 rotate by -270
set yrange [ 1024 : 4096 ] noreverse nowriteback
set zlabel "Z axis" 
set zlabel  offset character -5, 0, 0 font "" textcolor lt -1 norotate
set paxis 1 range [ * : * ] noreverse nowriteback
set paxis 2 range [ * : * ] noreverse nowriteback
set paxis 3 range [ * : * ] noreverse nowriteback
set paxis 4 range [ * : * ] noreverse nowriteback
set paxis 5 range [ * : * ] noreverse nowriteback
set paxis 6 range [ * : * ] noreverse nowriteback
set paxis 7 range [ * : * ] noreverse nowriteback
set colorbox vertical origin screen 0.9, 0.2, 0 size screen 0.05, 0.6, 0 front  noinvert bdefault
x = 0.0
# Last datafile plotted: "$grid"
splot 'data.tsv' using 1:2:3 

However, the above script is giving me the following error:

"3d.gp", line 37: warning: No usable data in this plot to auto-scale axis range

splot 'data.tsv' using 1:2:3 
                             ^
"3d.gp", line 37: All points z value undefined

Upvotes: 0

Views: 1345

Answers (1)

PinkFloyd
PinkFloyd

Reputation: 2193

Format the data.tsv file like this :

640000  1024    5220
640000  2048    3597
640000  4096    4088

320000  1024    7284
320000  2048    4940
320000  4096    3373

160000  1024    8417
160000  2048    5128
160000  4096    4661 

and plot the data with

splot 'data.tsv' using 1:2:3  w l

I did a sucessful test just with that last gnuplot command... if you want something more fancy, I can try to help

Upvotes: 1

Related Questions