hendry
hendry

Reputation: 10863

Dynamically colored bar charts in Gnuplot?

Without choosing the color explicitly like Different coloured bars in gnuplot bar chart? is there a way for GNU plot to choose some distinguished colors based on the key (like a hash?)?

bars with same color

# git rev-list --count master
$commits << EOD
gecko 716280
webkit 226748
blink 906439
EOD

set terminal png
set yrange [0:*]      # start at zero, find max from the data
set boxwidth 0.5      # use a fixed width for boxes
unset key             # turn off all titles
set style fill solid  # solid color boxes
set title 'commits'
plot '$commits' using 2:xtic(1) with boxes

Bonus: Instead of 1x10^6 (which I find odd), could it simple say 716k, 227k, 906k. I.e. the scale is in the 1000s for the Y axis.

Upvotes: 0

Views: 409

Answers (1)

Fabiola
Fabiola

Reputation: 74

The solution provided in Different coloured bars in gnuplot bar chart? works also without defining the linetypes. Gnuplot will use the default ones.

set yrange [0:*]      # start at zero, find max from the data
set boxwidth 0.5      # use a fixed width for boxes
unset key             # turn off all titles
set style fill solid  # solid color boxes
set title 'commits'
plot '$commits' using 0:2:($0+1):xtic(1) with boxes lc variable

enter image description here

You can also use one of the other predefined sequences of colors adding the following line:

set colors {default|classic|podo}

Upvotes: 1

Related Questions