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.
  2 件のコメント
madhan ravi
madhan ravi 2019 年 1 月 8 日
when asking a question provide the datas first
Manish Kumar
Manish Kumar 2019 年 1 月 8 日
Here is the data, Please help me.

サインインしてコメントする。

採用された回答

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')
Manish Kumar
Manish Kumar 2019 年 1 月 8 日
Thank you sir, its working

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeLine Plots についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by