Dear All, I have two set of data column x and y. I have plotted plot (x,y). y is oscillatory. I want to shade the area above and below x axis with different colors like shown in image. Can anyone please help me. I have attached the data in excel she

조회 수: 2 (최근 30일)
Two columns of data x and y, importing and polt them. Y is oscilatory, so i want to fill the graph with different colors such that above x axis one color and below x axis, another color.

채택된 답변

Stephen23
Stephen23 2019년 1월 8일
Use area. You might need to plot the data twice to get the effect you want.
  댓글 수: 2
Robert U
Robert U 2019년 1월 8일
Example:
x = 0:0.2:100;
y = ( x - ( 100 - x ) ).* cos(x);
yGzero = (y>0).*y;
yLzero = (y<=0).*y;
area(x,yGzero,'FaceColor','r')
hold on
area(x,yLzero,'FaceColor','black')

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Line Plots에 대해 자세히 알아보기

태그

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by