Adding transparency when filling color in plots

242 ビュー (過去 30 日間)
shane watson
shane watson 2019 年 12 月 5 日
コメント済み: shane watson 2019 年 12 月 10 日
Hello,
I have question regarding the transparency, I wanted to fill the my plots with transprent color as there are four plots, so trying to show all of them. Here the code I'm trying,
z=rand(1,24);
s=rand(1,24);
t=rand(1,24);
time=1:24;
EP=[13.2 13.2 9.4 9.4 9.4 9 9 9 9 7 9 9 0 0 0 0 0 0 0 9 9 9 9 7];
x = time;
y = EP;
bottom = 0;
plot(x,y)
hold on
fill([x,fliplr(x)],[y,bottom*ones(size(y))], 'g')
hold on
z= New2
bottom =0;
plot(x,z)
hold on
fill([x,fliplr(x)],[z,bottom*ones(size(z))], 'b')
hold on
s=New3;
bottom = 0;
plot(x,s)
hold on
fill([x,fliplr(x)],[s,bottom*ones(size(s))], 'r')
hold on
t=New4;
bottom = 0;
plot(x,t)
hold on
fill([x,fliplr(x)],[t,bottom*ones(size(t))], 'y')
hold on
set(gca,'color','w','FontSize',7,'FontWeight','Bold','XTickLabelRotation',45,'XTick',1:24, 'XTickLabel',{'1' '1' '2' '3' '4' '5' '6' '7' '8' '9' '10' '11' '12' '1' '2' '3' '4' '5' '6' '7' '8' '9' '10' '11'});

採用された回答

Adam Danz
Adam Danz 2019 年 12 月 5 日
You can specify any of the patch properties to change your patch objects. To change transparency, set the FaceAlpha value (and maybe the EdgeAlpha).
h = fill(. . .);
h.FaceAlpha = 0.5; % for 50% transparent
% or
h = fill(. . .,'FaceAlpha',0.5)
  3 件のコメント
Adam Danz
Adam Danz 2019 年 12 月 5 日
Happy to help.
shane watson
shane watson 2019 年 12 月 10 日

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

その他の回答 (0 件)

カテゴリ

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

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by