如何在gnuplot中生成具有可变框宽的盒须图?

时间:2013-03-14 08:12:44

标签: statistics gnuplot data-visualization boxplot

我正在尝试使用gnuplot可视化我拥有的数据集(在Java中,但这并不重要)。我可以就此问一些不同的问题,但是现在:假设我的数据是分类的,对于每个类别,我有四分位数1,2,3,最小值和最大值,以及该类别中样本的总重量(但不是实际样本数据)。我想用GNUplot'candlestick'来绘制这个。我几乎可以得到这个:

the 'candlesticks' plot

除了使用盒子宽度可视化样品的重量。

这可以在gnuplot'烛台'情节中完成吗?其他一些方式?

注意:我最感兴趣的是使用gnuplot。其他建议只有在它们易于编写脚本并且不需要安装太多额外软件时才受欢迎。

1 个答案:

答案 0 :(得分:12)

好的,明白了。

示例脚本:

set terminal pngcairo  transparent enhanced font "arial,10" fontscale 1.0 size 500,    350 
set output 'candlesticks.png'
set boxwidth 0.2 absolute
set title "Box-and-whisker plot with median bar, whiskerbars, and variable box width" 
set xrange[0:5]
set yrange[0:25]

# Data columns: X Min 1stQuartile Median 3rdQuartile Max BoxWidth Titles

# set bars 4.0
set style fill empty
plot 'data.txt' using 1:3:2:6:5:7:xticlabels(8) with candlesticks title 'Quartiles' whiskerbars, \
  ''         using 1:4:4:4:4:7 with candlesticks lt -1 notitle

data.txt的示例内容:

# Data columns: X Min 1stQuartile Median 3rdQuartile Max BoxWidth Titles
1 5 7 10 15 24 0.3 Quick
2 6 8 11 16 23 0.4 Fox
3 5 7 11 17 22 0.5 Lazy
4 6 9 10 18 21 0.3 Dog

(并注意#行只是注释,我们并没有真正指定列名。)

结果:

Plot