Search code examples
gnuplot

Linear inequality plot with shading


I simply want to show a linear equation -2x + 7 >= y with one side of the line shaded. I've tried various filledcurve iterations to no avail. Something so simple shouldn't be this difficult methinks.


Solution

  • Please do a reasonable search before you ask and provide your (non-working) code. Have you checked help filledcurves? What exactly is not clear there? Check the example below:

    Code:

    ### fill area below or above curve
    reset session
    
    set grid x,y front
    set style fill solid 0.3
    
    f(x) = -2*x+7
    
    plot f(x) w filledcurves x1 lc "red", \
         f(x) w filledcurves x2 lc "green", \
         f(x) w l
    
    ### end of code
    

    Result:

    enter image description here