Discover MakerZone

MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

Learn more

Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply Today

Thread Subject:
Transparency and geoshow questions?

Subject: Transparency and geoshow questions?

From: AL

Date: 4 Jul, 2008 01:29:02

Message: 1 of 3

Hello,

  I am still trying to solve a problem of removing NaN data
from my image created using geoshow. The NaN data is
visible as the lowest values from the colorbar. I changed
this to purple for better visualization:

http://i14.photobucket.com/albums/a345/ture1945/Junk/bad_NaN
.jpg

  I tried to make the NaN values transparent using
Alphadata but it does not seem to be working. I am not sure
if this is my bad programming or that Alphadata doesn't
work in geoshow? My code is at the bottom of this post.

 Some questions I have:

1) Does goeshow produce a surface, axes, or object? The
help seems to refer to all three...

2) Does AlphaData work with geoshow? I don't seem to be
getting errors but I can't get the result I want (likely
bad writing on my part).

******************************************
% zf is a matrix of ocean temperatures

inzf=ones(720,1440);
inzf(isnan(zf))=0; % index where NaNs are zeros

figure
geoidrefvec=[4 90 0];
geoidlegend=[4 90 0];


axesm('MapProjection','pcarree','FLatLimit',[10
50],'FLonLimit',[110 150],...
'FLineWidth',
[2],'Grid','on','GColor','black','MeridianLabel','on',...
'MLabelLocation',[10],'MLineLocation',
[2],'MLabelParallel','south',...
'ParallelLabel','on','PLabelLocation',[10],'PLineLocation',
[2])


Hg2=geoshow(zf,
geoidrefvec, 'DisplayType', 'texturemap','FaceAlpha','textur
emap'...
    ,'AlphaDataMapping','direct','AlphaData',inzf);

caxis([-3 3])
set(gcf,'colormap',Ac)
colorbar

set(gcf,'units','inches')
set(gcf,'position',[1 2 7.5 6.5])

geoshow('landareas.shp', 'FaceColor', [ .3 .7 .3]);

Subject: Transparency and geoshow questions?

From: Rob Comer

Date: 16 Jul, 2008 15:59:21

Message: 2 of 3

Answers to your questions:

1) Does goeshow produce a surface, axes, or object? The
help seems to refer to all three...

GEOSHOW constructs different types of graphics objects
depending on its inputs. In the case of raster input (as in
your example), it constructs a surface. It also constructs
an axes if you don't have one already.


2) Does AlphaData work with geoshow? I don't seem to be
getting errors but I can't get the result I want (likely
bad writing on my part).

Yes, you should be able to use AlphaData with GEOSHOW, but
this is a tricky topic -- don't blame your coding. The thing
is that of the three MATLAB renderer options, only 'opengl'
can provide transparency, regardless of your AlphaData
values. Meanwhile, in older versions the Mapping Toolbox
AXESM function coerced the renderer to 'zbuffer'. That's
likely to be what's happening here. Try:

>> get(gcf,'Renderer')

to see what renderer your figure is actually using. Then try

>> set(gcf,'Renderer','opengl')

or

>> set(gcf,'RendererMode','auto')


For more background, see the R2007b release note entitled
"Map Axes Now Display Transparent Objects More Easily":

http://www.mathworks.com/access/helpdesk/help/toolbox/map/rn/bq7mua5.html#brbixhw

and the bug report entitled "Specifying transparency has no
effect for objects in a map axes":

http://www.mathworks.com/support/bugreports/details.html?rp=240169


Rob Comer
Mapping Toolbox Development
The MathWorks, Inc.

Subject: Transparency and geoshow questions?

From: AL

Date: 18 Jul, 2008 01:35:03

Message: 3 of 3

Thanks Rob, great answers! I'll check it out!

-Allon

Tags for this Thread

What are tags?

A tag is like a keyword or category label associated with each thread. Tags make it easier for you to find threads of interest.

Anyone can tag a thread. Tags are public and visible to everyone.

Contact us