Filter löschen
Filter löschen

How to make contourf image semitransparent?

22 Ansichten (letzte 30 Tage)
JZ
JZ am 2 Aug. 2022
Kommentiert: DGM am 12 Jul. 2024 um 15:24
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?

Akzeptierte Antwort

Bhanu Prakash
Bhanu Prakash am 11 Jul. 2024 um 17:47
Bearbeitet: Adam Danz am 12 Jul. 2024 um 14:57
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 Kommentare
Adam Danz
Adam Danz am 12 Jul. 2024 um 14:58
Thanks @Bhanu Prakash & @DGM, I added the release info to the answer.
DGM
DGM am 12 Jul. 2024 um 15:24
Thanks Adam. Idk what happened there, but this is a good outcome.

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (0)

Kategorien

Mehr zu Purple finden Sie in Help Center und File Exchange

Tags

Produkte


Version

R2019b

Community Treasure Hunt

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

Start Hunting!

Translated by