Gnuplot filledcurves flip axes

前端 未结 2 1463
慢半拍i
慢半拍i 2020-12-12 03:50

There is a style to fill the space between two functions of x. Examples of such plots can be found e.g. at http://gnuplot.sourceforge.net/demo/fillbetween.html Is there any

2条回答
  •  一向
    一向 (楼主)
    2020-12-12 04:36

    You can't do this directly. From help filledcurves:

    The third variant fills the area between two curves sampled at the same set of x coordinates. It requires three columns of input data (x, y1, y2).

    I don't think you can specify (y, x1, x2) directly. As a workaround you can the area between the y axis and the larger function in some color, and then fill the area between the y axis and the smaller function in white:

    x1(y) = cos(y)+1
    x2(y) = cos(y)+2
    xmax(y) = (x1(y) > x2(y) ? x1(y) : x2(y))
    xmin(y) = (x1(y) < x2(y) ? x1(y) : x2(y))
    
    plot '+' using (xmax($1)):1 with filledcurve y1, \
         '+' using (xmin($1)):1 with filledcurve y1 fillcolor rgb "white"
    

    This probably has to be tweaked a little if one or both of the two functions can be negative.

提交回复
热议问题