让gnuplot并排放置条

让gnuplot并排放置条,gnuplot,bar-chart,Gnuplot,Bar Chart,我有以下gnuplot脚本: set autoscale unset log unset label unset term unset output set xtics rotate by -90 set ytic auto unset title set xlabel "Survey metadata attribute subset" set ylabel "Accuracy of classifier (%)" set boxwidth 0.1 set style fill solid s

我有以下gnuplot脚本:

set autoscale
unset log
unset label
unset term
unset output
set xtics rotate by -90
set ytic auto
unset title
set xlabel "Survey metadata attribute subset"
set ylabel "Accuracy of classifier (%)"
set boxwidth 0.1
set style fill solid
set term eps
set output "metadata.eps"
plot "metadata.dat" using 1:3:xtic(2) title "PART" with boxes, \
     "metadata.dat" using 1:5:xtic(2) title "JRip" with boxes, \
     "metadata.dat" using 1:7:xtic(2) title "FURIA" with boxes

但是,这会将所有3组条画在彼此的顶部,而我希望它们并排排列,按顺序分组在一起。所以它应该是这样的:PARTbar,jribbar,FURIAbar,gap,PARTbar,jribbar,FURIAbar,gap,等等。我该怎么做呢?

假设您的数据如下所示

1 a 2 3 4
2 b 1 4 5
3 c 6 7 8
一个选项是将boxwidth设置得更小,并手动调整长方体位置,使其对齐

我们可以用

set boxwidth 0.25
plot datafile using ($1-0.25):3 with boxes t "First Series", \
     "" using 1:4:xtic(2) with boxes t "Second Series", \
     "" using ($1+0.25):5 with boxes t "Third Series"
这将导致下图

<>请注意,我只在第二个系列中设置了XTIC,中间的一个,然后从第一个系列X坐标中减去了一个方块单位,然后把它添加到最后一个系列中,用一个盒子单元把它向前移动。我选择将boxwidth设置为0.25而不是0.33,以便在组之间留出一点间隙。把XTIC只放在第二个系列上,确保它在中间的一个。对于更多的框,您将使用不同的宽度,并且必须确定在哪个框上设置xtic标签

另一种方法是使用直方图样式。使用默认的boxwidth 1,您可以

plot datafile u 3 with histogram t "First Series", \
     "" u 4:xtic(2) with histogram t "Second Series", \
     "" u 5 with histogram t "Third Series"
在本例中,将xtic规范放置在何处并不重要

直方图样式非常复杂,有很多选项。本质上,它由多个打印样式组成,这些样式都是通过直方图规范调用的


选择哪一种方法主要取决于个人偏好。第一个是在添加直方图样式之前如何执行此操作。box方法可以让您对最终结果进行更多的手动控制,但直方图样式会自动处理许多细节,以确保这些方框正确无误。

假设您的数据如下所示

1 a 2 3 4
2 b 1 4 5
3 c 6 7 8
一个选项是将boxwidth设置得更小,并手动调整长方体位置,使其对齐

我们可以用

set boxwidth 0.25
plot datafile using ($1-0.25):3 with boxes t "First Series", \
     "" using 1:4:xtic(2) with boxes t "Second Series", \
     "" using ($1+0.25):5 with boxes t "Third Series"
这将导致下图

<>请注意,我只在第二个系列中设置了XTIC,中间的一个,然后从第一个系列X坐标中减去了一个方块单位,然后把它添加到最后一个系列中,用一个盒子单元把它向前移动。我选择将boxwidth设置为0.25而不是0.33,以便在组之间留出一点间隙。把XTIC只放在第二个系列上,确保它在中间的一个。对于更多的框,您将使用不同的宽度,并且必须确定在哪个框上设置xtic标签

另一种方法是使用直方图样式。使用默认的boxwidth 1,您可以

plot datafile u 3 with histogram t "First Series", \
     "" u 4:xtic(2) with histogram t "Second Series", \
     "" u 5 with histogram t "Third Series"
在本例中,将xtic规范放置在何处并不重要

直方图样式非常复杂,有很多选项。本质上,它由多个打印样式组成,这些样式都是通过直方图规范调用的

选择哪一种方法主要取决于个人偏好。第一个是在添加直方图样式之前如何执行此操作。box方法为您提供了对最终结果的更多手动控制,但直方图样式自动化了许多细节,使这些框变得恰到好处。

我想您需要的是设置样式直方图集群

我已经取得了一个最小的数据集,请参见下图

set style histogram clustered
set xtics rotate by -90
unset title
set xlabel "Survey metadata attribute subset"
set ylabel "Accuracy of classifier (%)"
set boxwidth 1
set style fill solid
set term png
set output "so.png"
plot [-0.5:2.75][1:17] "so.dat"using 3:xtic(2) title "PART" with histograms, \
     "" using 4 title "JRip" with histograms, \
     "" using 5 title "FURIA" with histograms
产生

我想你可以从这里走得更远

数据文件so.dat:

1   a   10  12  15
2   b   12  14  16
3   c   11  15  14
我想你想要的是设置样式

我已经取得了一个最小的数据集,请参见下图

set style histogram clustered
set xtics rotate by -90
unset title
set xlabel "Survey metadata attribute subset"
set ylabel "Accuracy of classifier (%)"
set boxwidth 1
set style fill solid
set term png
set output "so.png"
plot [-0.5:2.75][1:17] "so.dat"using 3:xtic(2) title "PART" with histograms, \
     "" using 4 title "JRip" with histograms, \
     "" using 5 title "FURIA" with histograms
产生

我想你可以从这里走得更远

数据文件so.dat:

1   a   10  12  15
2   b   12  14  16
3   c   11  15  14