在我的数据文件中,我有三列:一个字符串和两个数值。现在,我想使用创建3D图gnuplot
。不幸的是,我收到以下错误:
Need 1 or 3 columns for cartesian data
这是我的数据文件:
"Str1" 0 0
"Str1" 1 0
"Str1" 2 0
"Str2" 0 10
"Str2" 1 10
"Str2" 2 10
"Str3" 0 10
"Str3" 1 10
"Str3" 2 10
这是我的gnuplot脚本:
set surface
set contour surface
set view 60, 30, 1, 1
set clabel '%8.2f'
set key right
set title "Graph Title"
set xlabel "X Axis Label"
set ylabel "Y Axis Label"
set zlabel "Z Axis Label"
set term pdfcairo color dashed font 'FreeSans,9'
set output "output.pdf"
splot "data2.txt" using xtic(1):2:3 notitle
set output
我不明白问题是什么。我已经在2D图形中使用了xtic。此外,还有三个“坐标”。我是否必须为x轴定义一些特殊的东西?
谢谢!
更新:
下图是使用此脚本生成的:
set grid
set view 60, 30, 1, 1
set clabel '%8.2f'
set key right
set title "Graph Title"
set xlabel "X label (String)"
set ylabel "number 1"
set zlabel "number 2"
set xtics ("Str1" 0, "Str2" 1, "Str3" 2)
set term pdfcairo color dashed font 'FreeSans,9'
set output "rpiCluster2.pdf"
splot "data2.txt" using (int($0)/3):2:3 with linespoints
set output
在xtic
没有坐标,而是一个字符串。您仍然需要一个x坐标:
splot "data2.txt" using (int($0)/3):2:3:xtic(1) notitle
请注意,标签不会多次书写,而只能书写一次。
为了获得自动解决方案,您可以使用stats
命令。那不是直接计算块,而是空行。对于您的测试数据,以下工作正常:
stats "data2.txt" using 2 nooutput
n = int(STATS_records/(STATS_blank + 1))
splot "data2.txt" using (int($0)/n):2:3:xtic(1) notitle
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句