File Exchange

image thumbnail

Shaded pseudo color

version (772 KB) by Jody Klymak
Use shading to represent secondary information of an image

1 Download

Updated 06 Mar 2007

View License

shadedpcolor displays one dataset in color, and a second by varying the intensity of the pixels in the image. We use this for displaying the vertical gradients in a field on top of the field itself. It really makes the field more three-d. A similar effect can be achieved by using lighting, but this is much more deterministic.

For the above picture I ran:

shadedpcolor(x,z,U,(dU),[-1 1]/4,[-1 1]/300,0.7,cmp,0);
axis ij;
shadedcolorbar('v',[-1 1]/4,0.7,cmp);

Cite As

Jody Klymak (2020). Shaded pseudo color (, MATLAB Central File Exchange. Retrieved .

Comments and Ratings (3)

Hi Jody

Could you help me figure out how to get a handle for the figure.

If I run the code like this:
h=shadedpcolor(x,y,data,(data_slope)),[-3 3],[0 1],0.55,mycmap,0);

this is what happens
hp =


??? Output argument "h" (and maybe others) not assigned during call to "G:\For blog\Campi slope\shadedpcolor.m (shadedpcolor)".

Error in ==> shadedpcolor at 31
if nargin==0

But hp is not stored in a variable that I can use.

If I simply run the code without output arguments, like this:
shadedpcolor(x,y,data,(data_slope)),[-3 3],[0 1],0.55,mycmap,0);

I get
hp =


no error messages, but still cannot get a handle.


The figures resulting from the code snippet above are in the submission Perceptually improved colormaps (example2). Thank you

This is a great way to add shading to your data. I used it with very nice results with gravity anomalies with this code:

% slp=1-normalized_slope;
% shadedpcolor(x,y,residual,slp,[clim residual],[clim slp],0.55,jet(256),0);
% axis equal; axis off; axis tight;
% shadedcolorbar([clim residual],0.55,jet(256));

MATLAB Release Compatibility
Created with R2006b
Compatible with any release
Platform Compatibility
Windows macOS Linux

Inspired by: freezeColors / unfreezeColors

Inspired: Perceptually improved colormaps, dcolor