具有一种不同颜色条的 Gnuplot 框

Gnuplot boxes with one different color bar

我正在绘图,我需要显示另一种颜色的最后一个柱。我该怎么做?

这是我的代码

set output 'mediaedad.png'
set title 'Media de edad de los equipos'
set term png
set ylabel 'Edades'
set yrange [0:40]
set xlabel 'Equipo'
set xtics rotate
set style fill solid border
set boxwidth 0.5
set datafile separator comma
set grid nopolar
plot 'mediaequipos.txt' using 2:xtic(1) notitle with boxes

还有我的剧情

OP 没有指定颜色,所以我假设任何颜色都可以满足要求 "the last bar of another color"。 数据也不可用,因此我生成了一个小集合存储在文件中: "gnuptest_bars.txt".

a,1
b,2
c,2.2
d,3

同样基于此答案 () 的可能解决方案如下:

set title 'Media de edad de los equipos'

set ylabel 'Edades'
set yrange [0:5]
set xlabel 'Equipo'
set xtics rotate
set style fill solid border
set boxwidth 0.5
set datafile separator comma
set grid nopolar
plot 'gnuptest_bars.txt' using 2:xtic(1) notitle with boxes

N=system("cat gnuptest_bars.txt | wc -l")
plot "gnuptest_bars.txt" u 0:2:((int([=11=])+1)%N==0?(255<<16):255):xticlabels(1) with boxes lc rgbcolor variable notitle