How to 'turn off' blurry effect of imshow() in matplotlib?

后端 未结 2 1470
无人共我
无人共我 2020-11-29 05:03

I want to make a color plot of probabilities however imshow generates blurry values for points which have zero probability. How can I get rid of this blurry periphery around

相关标签:
2条回答
  • 2020-11-29 05:35

    By default (which is changed mpl 2.0), imshow interpolates the data (as you would want to do for an image). All you need to do is tell it to not interpolate:

    im = plt.imshow(..., interpolation='none')
    

    'nearest' will also work for what you want. See smoothing between pixels of imagesc\imshow in matlab like the matplotlib imshow for examples of all of the kinds of interpolation.

    doc

    0 讨论(0)
  • 2020-11-29 05:42

    You may also use:

    im = plt.imshow(..., interpolation='nearest')
    

    This works especially well for discrete variables.

    0 讨论(0)
提交回复
热议问题