gnuplotmaximawxmathplot

Highlighting section(s) of surface


I have analytically verified that a local min of x^2+y^2-x*y lies at the point (1,1) on the condition x+y=2. Using wxMaxima, can plot the surface

plot3d(x^2+y^2-x*y, [x,-2,2],[y,-2,2],[grid, 100,100], [mesh_lines_color,false]);

What I would like to do now is highlight all the points z on the surface that satisfy the condition x+y=2. In other words, I'd like to highlight the section of the surface given by the condition. How do I achieve this?


Solution

  • Since your question is tagged with gnuplot, here is a way how one could do that in Gnuplot using a parametric plot:

    set terminal pngcairo
    set output 'fig.png'
    
    unset key
    
    set isosamples 40
    set parametric
    
    set ur [-2:2]
    set vr [-2:2]
    set zr [0:12]
    
    set xr [-2:2]
    set yr [-2:2]
    
    fn(u) = 2-u
    
    splot \
        u,v,u**2 + v**2 - u*v, \
        u,fn(u),u**2 + fn(u)**2 - u*fn(u) w l lc rgb 'red'
    

    The output is then: enter image description here