How to make contourf image semitransparent?

1 回表示 (過去 30 日間)
JZ
JZ 2022 年 8 月 2 日
コメント済み: DGM 2024 年 7 月 12 日
I am using contourf to plot a 2D image in jet like below. Now I plan to make it semitransparent, therefore I may add some more lines. I tried all solutions searched online. Seems not working. Would anyone help me out?

採用された回答

Bhanu Prakash
Bhanu Prakash 2024 年 7 月 11 日
編集済み: Adam Danz 2024 年 7 月 12 日
Hi,
Starting in R2022b, to control the transparency of a 'contourf' plot, you can use the 'FaceAlpha' property in MATLAB. Here is an sample code for the same:
Z = peaks;
[M,c] = contourf(Z);
The range of 'FaceAlpha' is [0,1] with the deafult value being '1':
>> c.FaceAlpha
ans =
1
If you want to reduce the transparency, you can decrease the value of 'FaceAlpha' as follows:
c.FaceAlpha=0.3
Hope this helps!
  3 件のコメント
Adam Danz
Adam Danz 2024 年 7 月 12 日
Thanks @Bhanu Prakash & @DGM, I added the release info to the answer.
DGM
DGM 2024 年 7 月 12 日
Thanks Adam. Idk what happened there, but this is a good outcome.

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

その他の回答 (0 件)

カテゴリ

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

タグ

製品


リリース

R2019b

Community Treasure Hunt

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

Start Hunting!

Translated by