Adding transparency to a contour plot

조회 수: 231(최근 30일)
Rae Taylor-Burns
Rae Taylor-Burns 2020년 12월 1일
답변: Priyanka Rai 2020년 12월 28일
I have a contour plot, and I am looking to set the transparency of my contour plot to another variable and I cant figure out how to do this:
% color contour map
a = [1,2,3,4,5]
b = [.1, .5, 1, 2. 10]
c = a'*b
[X,Y] = meshgrid(a,b)
h = contourf(X,Y,c)
% transparency map
d = [5,4,3,2,1]
e = [10, 5, 1, 0.5, 0.1]
f = d'*e
[U,V] = meshgrid(d,e)
i = contourf(V,U,f)
I want the transparency of h to be determined by i. I can't figure out how to make this happen. FaceAlpha, AlphaData, etc are not working for me. Any help would be much appreciated!!


Michael 2020년 12월 18일
My understanding is that this isn't supported. In the past I have done a surface plot, changed the transparancy, and then changed the view to see it from above. Here is an example.
data = rand(100,100);
view([0 90])

Priyanka Rai
Priyanka Rai 2020년 12월 28일
mesh(___,Name,Value) specifies surface properties using one or more name-value pair arguments. For example, 'FaceAlpha',0.5 creates a semitransparent mesh plot. You can use this reference for further understanding: Mesh surface plot - MATLAB mesh (
You can control the transparency of an object using the alpha function or by setting properties of the object related to transparency. Some graphics objects support using a different transparency value for the faces versus the edges of the object. Refer this link for a detailed understanding of list of objects:
You could also refer to this article, which gives an understanding of how transparency options have changed over different MATLAB versions:



Community Treasure Hunt

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

Start Hunting!

Translated by