File Exchange

image thumbnail

Offsets and missing data via pcolor and surf

version (177 KB) by Chad Greene
A brief explanation of the half-pixel offset in pcolor and surf.

1 Download

Updated 01 May 2015

View Version History

View License

The pcolor and surf functions discard a row and column of data. Take a look at the example file (the light bulb icon) for a depiction of the effect.

Cite As

Chad Greene (2021). Offsets and missing data via pcolor and surf (, MATLAB Central File Exchange. Retrieved .

Comments and Ratings (5)



Oh, nevermind. Please disregard my comment, I see where you refer to the file. It could be nice to have it on the front page though too ;)


I like how you show the differences between the function very clearly.

One small comment: the 'rgb' function is not included here, but is called in the 'pcolor_offset' code.

Kevin Moerman

Nice illustration. Good to see more people are noticing/getting annoyed at this. These default MATLAB tools are in my opinion not suitable for image data. The slice function also has this flaw.

Kevin Moerman

See also ind2patch function which can avoid this. Additional documentation on this with HELP_ind2patch as part of GIBBON toolbox.
I would say it doesn't "discard" data. Rather that for patch graphics for these functions it interprets the data as defined on corners of pixels/voxels rather than on pixel/voxels centres as is meant for image data.

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

Community Treasure Hunt

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

Start Hunting!