使用 gnuplot 的一个 X 位置的两个箱线图

Two Boxplots for one X position using gnuplot

我有 2 组数据 A 和 B,每组的 y 值分别为 x=100、200、300。我想创建一个图表来显示这两个数据集之间的差异。因此,这意味着对于每个 x,将有两个箱线图(一个用于数据 A,一个用于数据 B)。

例如,这就是我的数据中列的组织方式。 数据集 A

#  x=100 200 300 
  1    2   3    
 1.1  2.1  3.1
 1.2  2.2  3.2
 1    2   3    
 1.01 2.01 3.01

数据集 B

#  x=100 200 300 
  6    7   9    
 6.1  7.1  9.1
 6.2  7.2  9.2
 6    7    9    
 6.01 7.01 9.01

我使用以下方法从这些数据中得到了两个图表:

set style fill solid 0.25 border -1
set style boxplot outliers pointtype 7
set style data boxplot
set xtics ('100' 1, '200' 2, '300' 3)
plot for [i=1:3] "A.txt" using (i):i notitle
plot for [i=1:3] "B.txt" using (i):i notitle

但是,我在将它合二为一时遇到了问题。 请帮忙。

如果你想让它们堆叠在一起(以防它们不重叠),那么你可以通过

将两个图合二为一
plot for [i=1:3] "A.txt" using (i):i notitle,\
     for [i=1:3] "B.txt" using (i):i notitle

如果它们可以重叠,您可能希望将它们与

并排放置
set boxwidth 0.3
plot for [i=1:3] "A.txt" using (i-0.15):i notitle,\
     for [i=1:3] "B.txt" using (i+0.15):i notitle

只是举两个例子说明如何组合这些图。