How to make contourf image semitransparent?

2 vues (au cours des 30 derniers jours)
JZ
JZ le 2 Août 2022
Commenté : DGM le 12 Juil 2024
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?

Réponse acceptée

Bhanu Prakash
Bhanu Prakash le 11 Juil 2024
Modifié(e) : Adam Danz le 12 Juil 2024
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 commentaires
Adam Danz
Adam Danz le 12 Juil 2024
Thanks @Bhanu Prakash & @DGM, I added the release info to the answer.
DGM
DGM le 12 Juil 2024
Thanks Adam. Idk what happened there, but this is a good outcome.

Connectez-vous pour commenter.

Plus de réponses (0)

Catégories

En savoir plus sur Data Distribution Plots dans Help Center et File Exchange

Tags

Produits


Version

R2019b

Community Treasure Hunt

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

Start Hunting!

Translated by