0

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.

hendry
  • 9,725
  • 18
  • 81
  • 139
  • 2
    See `help format specifier`. The command `set ytics format "%.0s%c"` will generate labels 100k 200k 300k ... 1M. – Ethan Jul 09 '20 at 02:23

1 Answers1

1

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}
Fabiola
  • 48
  • 5
  • Thank you. So it would appear `lc variable` is the magic I was after. – hendry Jul 10 '20 at 02:39
  • I have another question upon https://stackoverflow.com/questions/62828141/gnuplot-multi-column-plot-using-csv-headings – hendry Jul 10 '20 at 05:59
  • Can you explain `0:2:($0+1)` btw please? – hendry Jul 11 '20 at 10:46
  • The last column in the using specifier is required by 'lc variable' and it identifies the linetype index used to plot each row. Each linetype has its own color associated. $0 is the row number and it is here used to specify the index. – Fabiola Jul 13 '20 at 09:48