Gnuplot - 3D表面图

时间:2017-05-22 05:14:46

标签: drawing gnuplot

我正在尝试创建一个如下所示的3D曲面图: enter image description here

我试图以推荐的网格格式绘制data.tsv文件中包含的数据集,而不是绘制方程式。

8417    5128    4661
7284    4940    3373
5220    3597    4088

为清楚起见,上述数据的XYZ表示为:

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 

我用来获取所需输出的gnuplot脚本是:

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 

但是,上面的脚本给出了以下错误:

"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

1 个答案:

答案 0 :(得分:1)

data.tsv文件格式化为:

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 

并使用

绘制数据
splot 'data.tsv' using 1:2:3  w l

我用最后一个gnuplot命令做了一个成功的测试...如果你想要更有趣的东西,我可以尝试帮助