Contourf and a background image: how set transparency ?
Show older comments
Hello everyone. I have a contourf plot and I need to add in the same figure, as background image, a map. The issue is enhance trasparency of contourf layers.
I try to use my own code, helped by these forum, reported here:
% plotting image and contourf
img = imread('backgroud.png');
I=imagesc(img);
hold on;
[c,h]=contourf(X,Y,griddata(x,y,z,X,Y));
% setting trasparency
set(c, 'Renderer', 'OpenGL');
alphable = findobj(h, '-property', 'FaceAlpha');
set(alphable, 'FaceAlpha',0.5);
Even though the command 'Renderer' is applied directly to countourf's handles, this error occurs:
The name 'Renderer' is not an accessible property for an instance of class
'matlab.graphics.GraphicsPlaceholder'.
I'm working on a Matlab 2015b.
3 Comments
Lujendra Ojha
on 17 May 2018
I have the same problem. Any updates?
Shane L
on 17 May 2018
Answers (1)
Jeff Barton
on 22 Oct 2019
3 votes
Undocumentedmatlab.com has the solution (which involves FacePrims field):
(See "Customizing the color" section)
2 Comments
Alan Meier
on 12 Jul 2020
Kuifeng Zhao
on 16 Nov 2020
This works for me, Matlab 2020b. Thanks for sharing.
Categories
Find more on Lighting, Transparency, and Shading in Help Center and File Exchange
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!