Reputation: 161
I am making a plot and I need to show the last bar of another color. How can I do it??
This is my code:
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
And my plot:
Upvotes: 1
Views: 202
Reputation: 939
The OP didn't specify the color, so I assume any color would be fine if it satisfy the requirement "the last bar of another color". Data was also unavailable, therefore I generated a small set stored in the file: "gnuptest_bars.txt".
a,1
b,2
c,2.2
d,3
A possible solution, based also on this answer ( Gnuplot color every nth box in histogram) is the following:
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($0)+1)%N==0?(255<<16):255):xticlabels(1) with boxes lc rgbcolor variable notitle
Upvotes: 3