0
votes

I'm using gnuplot to plot bar graphs.

Here is my resulting graph: enter image description here

The question is: I want each bar to have different colors. For example: MSA-GA ACO in red and MSA-GA PACO in blue.

How do I do this?

Here are the comands I've used:

set yrange [0:14000]  
set style fill solid
set boxwidth 0.7
set xtics format ""
set grid ytics
set title "Total Runtime"
set ylabel "Time (s)"
unset key
plot "data.dat" u 1:3:xtic(2) with boxes, "" u 1:3:3 with labels offset char 0,0.7

The "data.dat":

0 "MSA-GA ACO"       12726.38
1 "MSA-GA PACO"      5290.00
1

1 Answers

1
votes

You can use linecolor variable with the boxes plotting style. The only thing to keep in mind is that you cannot change the color of linetype 0, so I add 1 to the value in the first column of your data file to select the color id:

set yrange [0:14000]  
set style fill solid
set boxwidth 0.7
set xtics format ""
set grid ytics
set title "Total Runtime"
set ylabel "Time (s)"
unset key
set linetype 1 lc rgb "red"
set linetype 2 lc rgb "blue"
plot "data.dat" u 1:3:($1+1):xtic(2) with boxes linecolor variable

enter image description here