Problem overlaying data on .gif
- From: katie.carbonari@xxxxxxxxx
- Date: Tue, 4 Dec 2007 13:25:31 -0800 (PST)
Hi there. I'm plotting some satellite data (latitude, longitude at
every time step) in a 2d histogram (using hist2d from mathworks) so I
know where my satellite has been. Now, I want to overlay with a map of
CONUS. Does anyone know of a good way to do this (without the mapping
toolbox)? hist2d uses pcolor to generate my plot (see below) and my
graph is just a .gif file. Everything I do just puts one graph on top
of the either and totally blocks out the bottom image/data. Is there a
way to make the "white" in either the .gif or the data become
transparent? Or am I totally on the wrong track? Any help would be
appreciated.
Thanks,
Katie
%%%My original code%%%
resolution=.125;
Conus_lat_lon=load('Conus_lat_lon.txt');
figure1=figure(5);
axes1=axes('Parent',figure1,'FontSize',16);
hold('all')
xlabel('Longitude','FontSize',24,'FontName','helvetica');
ylabel('Latitude','FontSize',24,'FontName','helvetica');
colorbar('Fontsize',16);title('Frequency of CALIPSO data over CONUS')
figure(5);hist2d(Conus_lat_lon(:,2),Conus_lat_lon(:,1),60/resolution,
25/resolution);colorbar;box off; grid off;
axis tight
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
tried adding this, but it didn't work:
[xx,map]=imread('conus.gif');
set(gcf,'Position',[40 32 716 520]);
colormap(map);
image(xx);
alpha(image(xx),.4)
%%hist 2d
%%%%%%%%%%%%%%%%%%%%%%%%%%
function [counto,xco,yco] = hist2d(x,y,nx,ny)
% HIST2D calculates a 2-dimensional histogram
% N = HIST2D(X,Y) bins the X and Y data into 10 equally spaced bins
in
% both dimension
%
% N = HIST2D(X,Y,M), where M is a scalar, bins the data into M
equally
% spaced bins in both dimensions
%
% N = HIST2D(X,Y,B), where B is a vector, bins the data with
centers
% specified by B
%
% The number of bins or centers can be specified individually for
either
% dimension using N = HIST2D(X,Y,NX,NY) or N = HIST2D(X,Y,BX,BY)
%
% [N,BX,BY] = HIST2D(...) also returns the positions of the bin
centers
% as two matrices in BX and BY
%
% HIST2D(...) without output arguments produces a colormapped image
plot
% of the 2d histogram
%
% EXAMPLE
% yin = randn(1,1000);
% xin = randn(1,1000);
% [n,x,y] = hist2d(xin,yin,11);
% imagesc(x(1,:),y(:,1),n); hold on; plot(xin,yin,'y.'); colorbar
if ~exist('nx')
nx = 10;
end
if ~exist('ny')
ny = nx;
end
if length(x) ~= length(y)
error(sprintf('x and y must be same size ( %g ~=
%g )',length(x),length(y)));
end
[dummy,xc] = hist(x,nx);
[dummy,yc] = hist(y,ny);
count = [];
for i = 1:length(yc)
if i == 1
lbound = -Inf;
else
lbound = (yc(i-1) + yc(i)) / 2;
end
if i == length(yc)
ubound = inf;
else
ubound = (yc(i) + yc(i+1)) /2;
end
count(i,:) = hist(x((y >= lbound) & (y < ubound)),xc);
end
[m,n]=size(count);
for i=1:1:m
for j=1:1:n
if count(i,j)==0
count(i,j)=NaN;
end
end
end
[xc, yc] = meshgrid(xc, yc);
if nargout == 0
pcolor(gca,xc(1,:),yc(:,1),count);
% imagesc(xc(1,:),yc(:,1),count);
else
counto = count;
xco = xc;
yco = yc;
end
.
- Prev by Date: inputs and outputs
- Next by Date: Re: Array problem
- Previous by thread: inputs and outputs
- Next by thread: getting data out of a struct array
- Index(es):
Relevant Pages
|