How to overlay a pcolor plot with a contour plot that uses a different flower card?

A minimal example that does not achieve this:

[X,Y,Z] = peaks; figure; pcolor(X,Y,Z); shading flat; hold all; axes; contour(X,Y,Z); colormap gray; % this should only apply to the contour plot axes... axis off; % ... but it doesn't 

This shows both the contour plot and the pseudo-color plot in the grayscale color scale. However, what I want to achieve only turns the outlines in gray.

This is just a minimalistic example, in reality, the contour graph has different data that has a different range, so two independent caxis settings are also required.

+6
matlab plot contour
source share
1 answer

You can fix the problem by linking the two color maps and making sure that the function values ​​are such that they refer to the right side of the color map:

 cm = [jet(64);gray(64)]; figure, pcolor(X,Y,Z) shading flat hold on %# Z in the contour starts after the maximum %# of Z in pcolor contour(X,Y,Z-min(Z(:))+max(Z(:))+2,'LineWidth',2) %# apply the colormap colormap(cm) 

enter image description here

For a more convenient solution, you can also take a look at this file sharing option of the week.

+4
source share

All Articles