Search code examples
gnuplothistogrampalette

gnuplot - filled curve with palette color


I'm trying to plot a histogram in gnuplot, where the bars are characterized by their color (intensity) instead of their height (frequency). To do so, I want to fill each bar with a color corresponding to the third column (which stands for this intensity) of a data file, defined in a palette. All the bars have the same height y=1 and the same width dx=1. The important part of the script looks like

plot for [ii=0:N] 'data.dat' index ii u 1:2:3 w filledcu y1=0 lc palette

My problem is that the ii=0 takes the right color of the palette and fills the first bar, but from there on all the others are the same color ( same intensity ) than ii=0.

My data file looks like:

X Y Intensity

1 1 0.6

2 1 0.6

...

Any idea to fill with the right color ?


Solution

  • The filledcurves plotting style doesn't support color gradients, see Gnuplot filledcurves with palette.

    Since you have the same height for every bar, you can use the boxes plotting style:

    set style fill solid noborder
    plot 'data.dat' using 1:2:3 with boxes lc palette