我想将Y值放在下图的直方图条形顶部: `
set style data histogram
#clustered
#set terminal wxt enhanced persist
set term post eps enhanced "Times-Roman, 14"
set output 'avg_waste.bmp'
set boxwidth 1.3
set grid
set auto y
set auto x
set style histogram clustered gap 1 title offset 1,0.25
set ylabel "\nAverage Resource Wastage\n\n\n" font "Times-Roman,25"
set xlabel "\nWorkflows\n" font "Times-Roman,25"
#set style fill solid noborder
set style fill pattern border -1
set key at graph 0.2, 0.9
set key spacing 2 font "Times-Roman,18"
set xtics font ", 25"
set ytics font ", 25"
plot for [COL=2:3] 'avg_waste' using COL:xticlabels(1) title columnheader fs pattern 2 `
当我尝试使用标签时,gnuplot会给出错误Not enough columns for this style
我的数据文件是
#WASTAGE
CRCH HEFT
Cybershake 20.89 22.5785714286
LIGO 187.3228571429 199.5134285714
SIPHT 205.7514285714 210.3685714286
Montage 12.1485714286 12.7942857143
答案 0 :(得分:3)
一种可能性是手动放置这些标签,例如:
reset
fontSpec(s) = sprintf("Times-Roman, %d", s)
set term post eps enhanced fontSpec(16)
set output 'avg_waste.eps'
set grid
set auto y
set auto x
ticsFont=fontSpec(16)
set xtics font ticsFont
set ytics font ticsFont
set ylabel "Average Resource Wastage" font fontSpec(25) offset char -1,0
set xlabel "Workflows" font fontSpec(25) offset 0,char -1
set style fill pattern border -1
set style data histograms
set boxwidth 1.0
set style histogram clustered gap 1
keyFont=fontSpec(18)
set key spacing 2 font keyFont
#using directly 'set key spacing 2 font fontSpec(18)' doesn't seem to work...
set key at graph 0.25, 0.9
fn(v) = sprintf("%.1f", v)
plot \
for [COL=2:3] 'avg_waste' using COL:xticlabels(1) title columnheader fs pattern 2, \
'avg_waste' u ($0-1-1./6):2:(fn($2)) w labels font fontSpec(14) offset char 0,0.5 t '' , \
'avg_waste' u ($0-1+1./6):3:(fn($3)) w labels font fontSpec(14) offset char 0,0.5 t ''
此外,由于您似乎想要使用从列标题中获取的标题,因此上述脚本假定输入数据的格式为:
WASTAGE CRCH HEFT
Cybershake 20.89 22.5785714286
LIGO 187.3228571429 199.5134285714
SIPHT 205.7514285714 210.3685714286
Montage 12.1485714286 12.7942857143
即,第一行没有注释掉。
编辑:
对于using
规范($0-1-1./6):2:(fn($2))
,它基于以下事实:条形的单个“块”以整数坐标0,1,2和3为中心。现在,每组有两个块,每个块的宽度为0.3(每组中心之间有2个块,空间有一个空块)。第0列$0
包含数据文件中特定行的从0开始的索引,因此例如对于“Cybershake”行,它等于1,因此语法($0-1-1./6):2:(fn($2))
然后告诉Gnuplot将函数fn
生成的标签放置在坐标-1./6,$2
处,即“Cybershake”组中左侧栏的顶部。这里,fn
仅用作“宏”来通过sprintf
函数格式化输入浮点数。