2
votes

My goal is to create a histogram with gnuplot 5.4 boxes, and have each box shaded with a specific RGB value (for testing purposes it is "green" but will be #RRGGBB in final data set)

My data looks like this:

5.800507    1   1   green
121.810653  6   1   green
133.411668  41  1   green

1st column - X value, 2nd column - Y value, 3rd column - box width, 4th column - rgb

This works and produces the expected graph output:

plot "data.out" using 1:2:3 with boxes

If I change the plot commend to this, it fails with the error "x range is invalid" and also gives the warning "Skipping data file with no valid points":

plot "data.out" using 1:2:3:4 with boxes lc rgb variable

I've found a number of examples in blogs for doing this with gnuplot 4.2, but all of them fail with the same "x range is invalid" error under 5.4.

1

1 Answers

2
votes

gnuplot cannot (yet?) use a color name as input for variable color. If you want to use a color name (as string) for lc var ..., check the following workaround: gnuplot: apply colornames from datafile

For your test case: simply change green to 0x00ff00.

Code:

### variable color
reset session

$Data <<EOD
5.800507    1   1   0x00ff00
121.810653  6   1   0x00ff00
133.411668  41  1   0x00ff00
EOD

set style fill solid 1.0

plot $Data using 1:2:3:4 with boxes lc rgb variable
### end of code

Result:

enter image description here