[Matplotlib-users] getting extra colors in figure

Antony Lee antony.lee at berkeley.edu
Tue Jul 26 14:18:54 EDT 2016


It may be worth adding a note to the example as to why this distinction
exists?  Right now it's a bit "magical"...
Antony

2016-07-26 10:47 GMT-07:00 Eric Firing <efiring at hawaii.edu>:

> On 2016/07/22 8:24 AM, Smit, Christine E. (GSFC-610.2)[TELOPHASE CORP]
> wrote:
>
>> Hi! I’m trying to plot data using imshow and ending up with more colors
>> than I specify in the colormap. This is causing problems with a downstream
>> user who is machine reading images to determine approximate data values
>> based on colors. I think the issue has something to do with rounding
>> because many colors in the image are only slightly off from the colors I
>> specified. My plots have exactly one pixel per data value, so each pixel¹s
>> color should be exactly a color in the colormap.
>>
>
> Christine,
>
> To solve the problem, try using interpolation = 'nearest' rather than
> 'none'.  The distinction between these is two is endlessly confusing, but
> http://matplotlib.org/examples/images_contours_and_fields/interpolation_none_vs_nearest.html
> is an attempt to illustrate it.
>
> In your example, with "nearest" I get 5 unique colors, not 6.
>
> Eric
>
> _______________________________________________
> Matplotlib-users mailing list
> Matplotlib-users at python.org
> https://mail.python.org/mailman/listinfo/matplotlib-users
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/matplotlib-users/attachments/20160726/aa5dfb3f/attachment.html>


More information about the Matplotlib-users mailing list