add transparency to a contourf
Ältere Kommentare anzeigen
I have an image (a DEM.tif) inserted in the above script where I plotted a map created with contourf. the code is:
[AA,EE]=geotiffread('dem_eu_rs.tif');
geoshow(AA,EE);
hold on
contourf(XX,YY,ZZ,500,'linecolor','none');
colormap jet
hold off
I should make the map transparent and therefore the contourf and not the .tif which instead must remain under the map.
I tried to write
s=contourf(XX,YY,ZZ,500,'linecolor','none');
colormap jet
hold off
alpha(s,.5)
but it made me transparent the DEM below instead of the variable s.
Can anyone help me?
Akzeptierte Antwort
Weitere Antworten (1)
The FaceAlpha and EdgeAlpha properties are new in R2022b.
I'm not familiar with cotourfm() or mapping tools, so I can't comment on that. If you just have an image and an overlaid contourf() that you want to be semitransparent, you can still do that.
One possible way is to simply set the alpha of the descendant objects that make up the contour plot. That's verbose, but it works back to R2014b. This also allows you to set the transparency of the contour levels individually if desired.
The other way is to flip the stacking order and make the image transparent instead. If the image and plot cover each other completely, this is pretty simple to do. If the contourf() plot doesn't cover the entire image area, you'll have to create a second copy of the image to use as a background behind the contourf(). If your image is single-channel, you'll have to expand it.
See the following answers:
Editing primitives:
Editing primitives and doing inverted stacking:
Comment on using grayscale images with colormapped graphics objects:
Kategorien
Mehr zu Contour Plots finden Sie in Hilfe-Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!


