[Matplotlib-users] getting extra colors in figure
Smit, Christine E. (GSFC-610.2)[TELOPHASE CORP]
christine.e.smit at nasa.gov
Tue Jul 26 14:12:29 EDT 2016
Thanks! I actually used ‘nearest’ before, but then ran into another issue:
https://github.com/matplotlib/matplotlib/issues/5520. It looks as though
the issue has been fixed, but I’m not sure where. The tag suggests to me
that it will be fixed in matplotlib 2.0.
I think that in this case matplotlib may actually be overkill. We are just
writing one pixel per data point, so I think it may be easier to just
write the png directly.
On 7/26/16, 1:47 PM, "Matplotlib-users on behalf of Eric Firing"
<matplotlib-users-bounces+christine.e.smit=nasa.gov at python.org on behalf
of efiring at hawaii.edu> wrote:
>On 2016/07/22 8:24 AM, Smit, Christine E. (GSFC-610.2)[TELOPHASE CORP]
>> 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
>> 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
>> color should be exactly a color in the colormap.
>To solve the problem, try using interpolation = 'nearest' rather than
>'none'. The distinction between these is two is endlessly confusing,
>is an attempt to illustrate it.
>In your example, with "nearest" I get 5 unique colors, not 6.
>Matplotlib-users mailing list
>Matplotlib-users at python.org
More information about the Matplotlib-users