2
votes

I guess, I've got an colormap issue with Matlab2013. I plot a 3d surface plot with colormap hot and I would like to have in the same plot an bitmap (8bit colour image) on the x-y plane. Plotting both separately from each other works fine but as soon as I plot them in one figure the first surface plot is only black. I guess it is because the RGB image on the x-y plane uses a different colour map. Is there an option in Matlab to plot two different type of images in the same plot?

surf(X,Y,density,'FaceColor','texturemap','Edgecolor','none')
colormap hot
...
%// define the location of the bitmap
xImage = [miX maX; miX maX];              %// The y data for the image corners
yImage = [miY miY; maY maY];              %// The x data for the image corners
zImage = [zDist zDist; zDist zDist];      %// The z data for the image corners  
surf(xImage,yImage,zImage,...             %// Plot the surface
    'CData',RGBImage,...
    'FaceColor','texturemap');

Thanks! Durin

1
Can you provide the image as well as the corresponding values in xImage, yImage and zImage?rayryeng

1 Answers

1
votes

I think this is an issue with the relative scaling of density and zImage. I can replicate this by doing the following:

1) Plot a surf where the third input is n x m which is scaled like some real data (-0.2 to +0.2, for example). This responds to changes in colormap as you'd expect.

2) After hold on, plot another surf where the third input is n x m x 3, like a RGB image, double values scaled between 0 and 1.

This causes the first image to go "dark" (or whatever the lowest color in that particular colormap is). The issue is that they share their CLim, being in the same axis, although the RGBImage doesn't, in fact, reference the colormap.

This is "fixable" by scaling/normalising the first plot (your density values) to be between 0 and 1 (in this case) - although this quick fix is going to give you issues if you then want to add a colorbar. Alternatively, first grab the "CLim" from your axis after plotting the first surf:

trueC = get(gca,'CLim');

Then set it back after you plot the image:

set(gca,'CLim',trueC)