-1

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 gives: gnuplot box graph

This does not match the defined palette. How can I make gnuplot use the defined palette here with the index and color names?

mwarning
  • 721
  • 5
  • 22

1 Answers1

0

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:

gnuplot colored boxes

mwarning
  • 721
  • 5
  • 22
  • if you had found this https://stackoverflow.com/q/55729706/7295599 or this https://stackoverflow.com/q/54658674/7295599 it certainly would have helped... – theozh May 11 '20 at 07:24
  • The first one would have been helpful, but does not seem to use a palette. – mwarning May 11 '20 at 11:04