在 Gnuplot v5.4.2 中,我想为来自不同文件的多个数据列制作箱线图,并将其合并到具有相同 y 值范围的一个多箱线图中。
我能做的是将数据合并到一个文件中,但是各列的条目数不同。我可以只指定 NaN (不是数字)或其他值,Gnuplot 会忽略它吗? 例如,当组合文件如下所示时:
"label 1" "label 2" "label 3"
12.3 44.2 13.3
12.4 12.5 14.4
11.6 13.7 NaN
NaN 15.7 NaN
我查看了http://www.gnuplot.info/demo_5.2/boxplot.html,但像 silver.dat 这样的文件中的标签是硬编码在 gplot 脚本中的,并且所有数据都具有相同的编号行数。
谢谢你。
假设我正确理解你的问题,你想在一张图中绘制来自不同文件和不同列的箱线图。
您必须以某种方式指定文件名和列,例如在字符串(列表)中。到目前为止,我还没有成功地将 xticlabels 与绘图样式
boxplot
一起使用。因此,文件被第二次“绘制”(实际上,NaN
被绘制,即没有绘制)以获得相应的列标题。
如需进一步阅读,请查看
help boxplot
、help word
、help words
、help xticlabels
、help columnhead
。
数据:
SO78599002_1.dat
# SO78599002_1
File1Col1 File1Col2 File1Col3 File1Col4
1 12 13 14
2 22 23 24
3 32 33 34
4 42 43 44
5 52 53 54
6 62 63 64
7 72 73 74
SO78599002_2.dat
# SO78599002_2
File2Col1 File2Col2 File2Col3
1 12 13
2 22 23
3 32 33
4 42 43
5 52 53
SO78599002_3.dat
# SO78599002_3
File3Col1 File3Col2
1 12
2 22
3 32
4 42
5 52
6 62
脚本:
### boxplots from different files and selected columns
reset session
FILES = "SO78599002_1.dat SO78599002_2.dat SO78599002_3.dat"
COLUMNS = "4 3 2"
set style fill solid 0.3
set key noautotitle
plot for [i=1:words(FILES)] word(FILES,i) u (i):int(word(COLUMNS,i)) w boxplot, \
for [i=1:words(FILES)] word(FILES,i) u (i):(NaN):xtic(columnhead(word(COLUMNS,i))) w p
### end of script
结果: