Shading an area boundered by a curve

后端 未结 3 2163
小鲜肉
小鲜肉 2020-12-09 22:42

What would be the easiest way to lightly shade (or hatch; or anything to set it different from the rest) an area in a plot(), below a curve y=x^2, for example ?



        
3条回答
  •  情深已故
    2020-12-09 23:25

    Without messing with children, you can also:

    x = 0:pi/10:2*pi;  % from your example
    y = x.^2.;    % from your example
    
    H=area(x,y);
    set(H(1),'FaceColor','k');
    alpha(.5);
    

    Worked for me, it also helped with some legend issues that I was having.

    . To kick a dead question

提交回复
热议问题