# Bogus colour gradients in imshow()

Hi,
I'm plotting some 2D grid data using imshow(). However, one of my test
problems involves a Gaussian peak in the center of my grid. For some
strange reason this Gaussian looks like 5 distinct peaks. It looks like
the values are only set at the centers of my grid cells and then the
colour gradients are interpolate from this central point and a
background.
You can have a look at the original plot and a magnified one at

Cheers,
Christian

Christian Lerrahn wrote:

Hi,
I'm plotting some 2D grid data using imshow(). However, one of my test
problems involves a Gaussian peak in the center of my grid. For some
strange reason this Gaussian looks like 5 distinct peaks. It looks like
the values are only set at the centers of my grid cells and then the
colour gradients are interpolate from this central point and a
background.
You can have a look at the original plot and a magnified one at

The problem is that the colors are being set at the points by looking them up in the colormap, and the intermediate colors are being interpolated between those looked-up colors (this may be the point you are trying to make, but I couldn't be sure). The peak color is correct; it only looks like it is lower than the four surrounding points because that colormap is not a very good one for this kind of data. Use a single-hue colormap, instead.

The alternative is to interpolate the *values* at the intermediate pixels first, and then look up the colors for each pixel in the colormap. This would give more reasonable results even with misapplied colormaps. However, it will probably be less efficient to implement.

···

--
Robert Kern

"I have come to believe that the whole world is an enigma, a harmless enigma
an underlying truth."
-- Umberto Eco

You can choose the kind of interpolation that gets used:

* interpolation is one of:

'nearest', 'bilinear', 'bicubic', 'spline16', 'spline36',
'catrom', 'gaussian', 'bessel', 'mitchell', 'sinc',
'lanczos', 'blackman'

if interpolation is None, default to rc

If you don't want interpolation at all, just solid filled squares, then use interpolation='nearest'.

Eric

Christian Lerrahn wrote:

···

Hi,
I'm plotting some 2D grid data using imshow(). However, one of my test
problems involves a Gaussian peak in the center of my grid. For some
strange reason this Gaussian looks like 5 distinct peaks. It looks like
the values are only set at the centers of my grid cells and then the
colour gradients are interpolate from this central point and a
background.
You can have a look at the original plot and a magnified one at

Cheers,
Christian

-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2008.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
_______________________________________________
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users