Gnuplot filledcurves with palette

后端 未结 6 996
有刺的猬
有刺的猬 2020-12-29 11:09

I have been trying to change the fillstyle for the filledcurves option in gnuplot so that the fill colour represents the difference between the two curves on a 2-dimensional

6条回答
  •  感情败类
    2020-12-29 11:35

    AFAIK, this is still not implemented in gnuplot. You can however have a dirty(*) work around by overlaying several transparent filled curves.

    E.g.,

    max_color=1
    max_diff=0.5
    N_col=6
    TRSP="E0"
    HOTCOL="FF0000"
    COLDCOL="0000FF"
    RGBA_HOT="#".TRSP.HOTCOL
    RGBA_COLD="#".TRSP.COLDCOL
    RGB_HOT="#".HOTCOL
    RGB_COLD="#".COLDCOL
    #red(val) = (val < 0 ? abs(1+val/max_color) : 1)
    #green(val) = (1 - abs(val)/max_color)
    #blue(val) = red(-val)
    #rgb(val) = 65536*int(255*red(val)) + 256*int(255*green(val)) + int(255*blue(val))
    fhot(x) = 0.1*exp(-((x-400)/200)**2) + 0.8*exp(-((x-2000)/300)**2)
    fcold(x) = 0.25*exp(-((x-700)/100)**6)+ 0.4 - (2e-4*(x-2500))**2
    plot [400:2600] for [thr=0:N_col] '+' using (((fhot($1)-fcold($1))/max_diff*N_col>thr)?$1:1/0):(fhot($1)):(fcold($1)) with filledcurves lc rgb RGBA_HOT title '',\
         for [thr=0:N_col] '+' using ((-(fhot($1)-fcold($1))/max_diff*N_col>thr)?$1:1/0):(fhot($1)):(fcold($1)) with filledcurves lc rgb RGBA_COLD title '',\
         '' using 1:(fhot($1)) with lines lw 4 lc rgb RGB_HOT t 'Hot',\
         '' using 1:(fcold($1)) with lines lw 4 lc rgb RGB_COLD t 'Cold'
    

    Adjust N_col and TRSP to change the gradient: number of filled curves overlaid and transparency of each (more curves implies to be closer to max transparency FE).

    (*) This is less dirty in case the information you want to plot is a discrete variable, e.g. the number of datasets available at given abscissae.

提交回复
热议问题