tiswas
tiswas

Reputation: 2101

Matlab - plot two pcolors on top of each other, with different colormaps

I'm plotting two pcolors on top of each other (using the m_map algorithm m_pcolor). The reason for this is that the second pcolor has transparency in it, and so shows the pcolor underneath. The first plot consists of just ones and zeroes, and I would like it to be just black and white. I would like the second to use the colormap jet, but I can't work out how to set one colormap without changing the other. My code at the moment is:

h1 = m_pcolor(Lon', Lat', black_background);
hold on; 
h = m_pcolor(Lon', Lat', input_matrix);

Thanks in advance, Adam

Upvotes: 0

Views: 1679

Answers (1)

tmpearce
tmpearce

Reputation: 12693

For this limited application, the easiest way is probably to append a row of zeros onto the colormap, deal with scaling (the clim property) yourself so that each plot takes advantage of the appropriate part of the colormap.

cm=colormap('jet'); %# Nx3
cm = [cm; 0 0 0]; %# append black row: (N+1)x3

h1 = m_pcolor(Lon',Lat',black_background);
set(h1,'clim',[length(colormap),length(colormap)])

hold on
h2 = m_pcolor(Lon', Lat', input_matrix);
set(h2,'clim',[length(colormap)-1, length(colormap)-1])

This should get you close, but I haven't tested it since I'm not on my matlab machine.

Another option is freezeColors from the file exchange (but this may only work for different axes within the same figure window, I'm not sure about different plots in the same axes object).

Upvotes: 1

Related Questions