自动删除gnuplot中方框图左侧的空白
以下是对这个问题的回答:以及我创建这个脚本的一些其他来源:自动删除gnuplot中方框图左侧的空白,gnuplot,Gnuplot,以下是对这个问题的回答:以及我创建这个脚本的一些其他来源: set terminal postscript eps enhanced color set title "Histogram\_CreatesFile" colour1="#00A0ff" colour2="navy" colour3="#ffA000" colour4="#800000" set output 'Histogram_CreatesFile.eps' set yrange [0:] set style fill so
set terminal postscript eps enhanced color
set title "Histogram\_CreatesFile"
colour1="#00A0ff"
colour2="navy"
colour3="#ffA000"
colour4="#800000"
set output 'Histogram_CreatesFile.eps'
set yrange [0:]
set style fill solid 0.8 border -1
bin_width = 0.2
set boxwidth bin_width
bin_number(x) = floor(x/bin_width)
rounded(x) = bin_width * ( bin_number(x) + 0.5 )
plot 'Histogram_CreatesFile.txt' using (rounded($1)):(1) smooth frequency with boxes lc rgb colour1 notitle
我有一个测试数据文件:
0
0.2
0.4
0.41
一切都很美好,但我在第一个酒吧左边有一个奇怪的空白处:
当我不知道apriori数据文件中的值是什么(即,它可能从0以外的值开始)时,如何使图形从第一个条开始?在我看来,
stats
命令可能会帮助您
set terminal postscript eps enhanced color
set title "Histogram\_CreatesFile"
colour1="#00A0ff"
colour2="navy"
colour3="#ffA000"
colour4="#800000"
set output 'Histogram_CreatesFile.eps'
set yrange [0:]
set style fill solid 0.8 border -1
bin_width = 0.2
set boxwidth bin_width
bin_number(x) = floor(x/bin_width)
rounded(x) = bin_width * ( bin_number(x) + 0.5 )
stats 'Histogram_CreatesFile.txt' using (rounded($1)) nooutput
set xrange [STATS_min-bin_width/2.:]
plot 'Histogram_CreatesFile.txt' using (rounded($1)):(1) smooth frequency with boxes lc rgb colour1 notitle
在gnuplot4.6(?)中添加了
stats
。在此之前,我一直使用的技巧是绘制到虚拟终端,并从特殊的只读变量GPVAL\u X\u MIN
中获取最小值stats
更干净、功能更强大,目前的稳定版本是4.6,因此应该使用它。还请注意,由于您对设置标题使用双引号字符串,因此可能需要两个反斜杠来防止增强文本将C
作为下标。或者,您可以使用我认为不增强的选项。