我有两个下面列出的数据文件 file1.dat
a b c d(There is no colum name in my file)
70.9 70.4 71.3 65.6
70.8 70.9 72.8 68.1
72.00 72.4 70.6 67.9
70.2 71.5 71.7 70.9
71.00 71.2 71.1 71.7
71.5 71.3 71.1 71.4
File2.DAT的
a b c d(There is no colum name in my file)
70.9 67.5 71.3 64.67
72.2 71.2 72.8 65.5
72.4 70.2 70.6 68.6
71.6 72.1 71.3 67.9
70.2 72.2 71.1 70.8
71.2 71.7 71.9 71.7
72.00 71.4 71.7 71.3
70.8 71.7 71.4 71.3
我想创建一个图a1,a2 b1,b2 c1,c2 d1,d2怎么可能?
代码:
set title "Unigram features ranked using MI of POSITIVE class"
set title font ", 20"
set xlabel "Feature Length"
set xlabel font ",20"
set ylabel "Accuracy(%)"
set yrange [65:75]
set ylabel font ",20"
set ytics font ", 20"
set boxwidth 0.98
set key font ",18"
set style fill pattern #solid
set style histogram clustered #gap 5 title offset character 0, 0, 0
set xtics font ", 20"
set xtics ("100" 0, "300" 1, "500" 2, "1300" 3, "1500" 4, "1800" 5, "1900" 6, "2000" 7)
set style data histograms
plot "< paste without_threshold_POSITIVE.dat with_threshold_POSITIVE.dat" using 1:5 every ::1, \
"" using 2:6 every ::1, \
"" using 3:7 every ::1, \
"" using 4:8 every ::1
set output 'POSITIVE_test.eps'
set terminal postscript eps enhanced black
replot
请找到代码..并尝试指出我的错误
答案 0 :(得分:1)
正如Christoph在评论中所提到的,您需要对数据进行预处理,paste
是一个很好的工具:
paste file1.dat file2.dat > file3.dat
会粘贴您的列。由于每个文件有4列,因此新file3.dat
列中的1到4列来自file1.dat
,第5列到第8列来自file2.dat
。因此,您需要绘制using 1:5
,using 2:6
,using 3:7
和using 4:8
:
plot "file3.dat" using 1:5 every ::1, \
"" using 2:6 every ::1, \
"" using 3:7 every ::1, \
"" using 4:8 every ::1
在every ::1
的地方我告诉gnuplot忽略你有非可绘制文本的第一行(你可以使用#
注释掉这一行)。你可以在gnuplot中进行paste
预处理而无需生成file3.dat
:
plot "< paste file1.dat file2.dat" using 1:5 every ::1, \
"" using 2:6 every ::1, \
"" using 3:7 every ::1, \
"" using 4:8 every ::1
答案 1 :(得分:0)
histogram
绘图样式只需要一列。我不完全确定,您希望如何安排a1,a2,b1,b2等列,以及您的手动xtics如何发挥作用。
我假设第一个x值对应第一行的标签,依此类推。
以下是如何在a2列下方设置a1框以进行比较:
set title "Unigram features ranked using MI of POSITIVE class"
set xlabel "Feature Length"
set ylabel "Accuracy(%)"
set yrange [65:75]
set boxwidth 0.98
set style fill solid
set style histogram clustered #gap 5 title offset character 0, 0, 0
set xtics ("100" 0, "300" 1, "500" 2, "1300" 3, "1500" 4, "1800" 5, "1900" 6, "2000" 7)
set style data histograms
plot "file1.dat" using 1 every ::1 t 'a1', \
"file2.dat" using 1 every ::1 t 'a2'
b1,b2列是否应该在a1,a2列之间对齐,即按行分组,或者在不同的直方图中彼此之下?
上述脚本的结果是(使用4.6.4):