#354 Filledcurves horizontal gradient from pallette

open
nobody
None
5
2013-02-10
2012-11-25
Alaric Taylor
No

I have been trying to change the fillstyle for the filledcurves option so that the fill colour represents the difference between the two curves on a 2-dimensional plot. I am thinking of this as an extension of the 'filledcurves above/below' option whereby instead of just having two colours representing above or below there is a colour range or palette.

Here is an example of the plot I would like to make from a datafile using the above/below filled curve style http://i.stack.imgur.com/RLlpU.png A colourbar representing the y-difference between the two curves would be very useful - an example plot of a filledcurve with a color map is attached.

I have tried to do this by adding a fourth column to the using command i.e.

plot 'data.txt' using 1:2:3:($3-$2) with filledcurves fs palette

but the filledcurves does not appear to accept the fourth column... I have also considered trying rgb variable but this doesn't seem to work either.

Discussion

  • Alaric Taylor
    Alaric Taylor
    2012-11-25

    Similar function in Matplotlib?

     
  • Ethan Merritt
    Ethan Merritt
    2012-11-25

    Gnuplot does not support gradient fill, in large part because the underlying graphics libraries do not.

    I'm not entirely sure I understand what you are aiming for, as the colors in the attached png file do not represent any obvious property. Is the coloring by gradient? Some otherwise unlabeled quantity?

    Anyhow, although there is no way to get gradient color between two smooth curves you could use plot style "with boxxy fillcolor palette" to get an unsmoothed version. The command would be something like
    prev = 0
    plot 'data.txt' using 1:2:(temp=prev,prev=$1,temp):1:3:2:($3-$2) \ with boxxy fc palette

     
  • Ingo Thies
    Ingo Thies
    2012-12-29

    There is no need to go for boxxy. Actually, one can do something similar using a dummy image as gradient background and filledcurves hiding the region above or below the curve. Here is a test script which plots a parabola with a rainbow-like color gradient below the curve. The script works at least for terminals X11 and PNG and gnuplot 4.6.1 or later.

    set palette defined ( 0 "blue", 3 "green", 6 "yellow", 10 "red" )
    f(x)=-x*x+1.
    xmin=-1.;xmax=1.
    ymin=0.;ymax=1.2
    set xrange [xmin:xmax];set cbrange [xmin:xmax]
    set y2range [0:1]#dummy yrange
    set yrange [ymin:ymax]#actual yrange using y2 axis
    unset colorbox
    unset y2tics; set ytics autofreq
    plot '++' using 1:2:1 axes x1y2 with image,\ f(x) axes x1y1 notitle w filledcurves below y1=ymax lc rgb "white",\ f(x) axes x1y1 t 'f(x)' w l lc rgb "#000000"