Search code examples
gnuplot

Filledcurves aera below|above curve


I tried to use an example in the demo folder, my goal is to define a color area above and below my blue line
Here is what I get :
enter image description here

And what I would like :
enter image description here

Code :

set style fill solid 0.50 noborder
set style data lines
set title "Fill area" 
set xrange [ 250.000 : 500.000 ] noreverse writeback
## Last datafile plotted: "silver.dat"
plot 'silver.dat' u 1:2:($3+$1/50.) w filledcurves above notitle, \
     '' u 1:2 w filledcurves lc rgb "light-salmon" notitle, \
     '' u 1:($3+$1/50.) lt 3 lw 2 title 'linemax"

Solution

  • At first, it should be noted that

    '' u 1:2 w filledcurves lc rgb "light-salmon" notitle, \
    

    will be interpreted as "filledcurves closed" by default.

    The filled area of the desired plot in "salmon-pink" color is the envelope of the minimum of the two curves. This curve representing the envelope cannot be represented by a single filledcurves because it switches in the middle of the data points. As a workaround, how about using two filledcurves to represent the envelope by filling the second plot with the background color (white)?

    set terminal wxt
    set style fill solid 0.5 noborder
    set style data lines
    set title "Fill area" 
    set xrange [ 250.000 : 500.000 ] noreverse writeback
    ## Last datafile plotted: "silver.dat"
    plot 'silver.dat' u 1:2:($3+$1/50.) w filledcurves above notitle, \
         ''           u 1:($3+$1/50.)   w filledcurves y=0 lc rgb "light-salmon" notitle, \
         ''           u 1:2:($3+$1/50.) w filledcurves below lt bgnd notitle, \
         ''           u 1:($3+$1/50.)   w lines lt 3 lw 2 title 'linemax"
    

    enter image description here