Underlay Image in Bar3 Plot

1 view (last 30 days)
Michael
Michael on 14 Jun 2011
I have a 25x25 matrix that I am performing the bar3 plot on. I am then taking the ZData from a second bar3 plot of a different 25x25 matrix, and making this ZData the CData for my first plot. I would like, however, to be able to insert an image in the X-Y Plane of this plot. I can do this via the code below, but the bar3 plot coloring becomes one solid color. I've tried using 'freezeColor' after plotting the image, but then the bar3 plot of my data doesn't show up. Essentially, I am looking to produce a bar3 plot, whose height corresponds to a magnitude for that 'block area' and whose color corresponds to a rate for that 'block area' and with an image anchored in the X-Y plane of the plot.
SP=FGM./FGA;
P=bar3(SP);
figure
%Insert Court Image
Z=imread('Court.jpg');
[X,map]=rgb2ind(Z,256);
x=1:25;
y=1:25;
[xx,yy]=meshgrid(x,y);
zz=zeros(size(xx));
colormap(map)
surf(xx,yy,zz,X,'FaceColor','texturemap','EdgeColor','none','CDataMapping','direct');
hold on
A=bar3(FGA);
%Convert ZData to "Complete" CData Matrix that Colors All Sides of Bars
for n=1:numel(P)
cdata=get(P(n),'zdata');
acdata=ones(150,4);
for i=2:6:150
pmax=cdata(i,2);
acdata(i-1:i+4,1:4)=pmax;
end
set(P(n),'cdata',acdata)
set(A(n),'cdata',acdata)
end

Answers (1)

Sean de Wolski
Sean de Wolski on 14 Jun 2011
My function: FEX: meshCanopy overlays a mesh on an image. If you look at the code for it you should be able to see how it's done and just change a few parameters or maybe even just the call to mesh to bar3.
Also, confirm that this type of figure is what you're looking for.
Welcome to MATLAB Answers!

Categories

Find more on Colormaps in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!