I try to map some index to a color of a defined palette. But the defined palette does not seem to get used.
Given a files data.txt
:
11
22
33
44
The gnuplot commands:
set nokey
set grid
set style fill solid
set boxwidth 0.5
set yrange [0:]
set palette model RGB maxcolors 7
set palette defined (0 'dark-violet', 1 'skyblue', 2 'dark-yellow', 3 'dark-green', 4 'dark-red', 5 'coral', 6 'green', 7 'purple')
plot 'data.txt' using 0:1:(column(0)+1) with boxes linecolor variable
This does not match the defined palette. How can I make gnuplot use the defined palette here with the index and color names?
This is the solution I came up:
set nokey
set grid
set style fill solid
set yrange [0:]
set palette defined (0 'dark-violet', 1 'skyblue', 2 'dark-yellow', 3 'dark-green', 4 'dark-red', 5 'coral', 6 'green', 7 'purple')
set cbrange [0 : 7]
unset colorbox
plot 'data.txt' using 0:1:(0.5):(column(0)) with boxes linecolor palette
The solution was to add the box width (0.5)
in the plot row and to use cbrange
and linecolor palette
: