How to reduce the gaps in the histogram gnuplot?

巧了我就是萌 提交于 2019-12-07 14:01:26

问题


gnuplot script:

set auto x
set yrange [0:100] 
set style data histogram 
set style histogram cluster gap 1
set style fill solid border -1 
set boxwidth 1  
plot 'test.data' using 1, '' u 2

test.data

80   15
71   81
81   71
61   75
57   17
80   80
82   91
86   73

output:

I need so:

How to reduce the gaps in the histogram gnuplot?


回答1:


I think you cannot do this with the clustered histogram style, because the gap option takes only integer numbers.

In your case with only two columns, you can use the boxes plotting style and shift the boxes belonging to the first column by half of the boxwidth to the left, and the boxes of the second column by the same amount to the right:

set auto x
set yrange [0:100] 
set style fill solid border -1
boxwidth=0.45

set boxwidth 0.45 absolute
set style data boxes
plot 'test.data' using ($0-boxwidth/2):1, '' u ($0+boxwidth/2):2

Result with 4.6.4:




回答2:


http://www.bersch.net/gnuplot-doc/histograms.html reports that you can use the "at x-coord" option with newhistogram in gnuplots to manually adjust the gap between clusters. I have used a combination of this, the "gap" option for set style histogram and "set offsets " command to move the clusters around on the graph. Hope this helps.




回答3:


You are looking for the gap keyword to the set style histogram command.

set style histogram clustered gap <width of gap>


来源:https://stackoverflow.com/questions/24166751/how-to-reduce-the-gaps-in-the-histogram-gnuplot

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!