Animation quality is better with matshow() than with imshow(). How to improve it? Animation quality is better with matshow() than with imshow(). How to improve it? arrays arrays

Animation quality is better with matshow() than with imshow(). How to improve it?


The issue is due to interpolation.

Matplotlib matshow is a wrapper for imshow, in that it "sets origin to ‘upper’, ‘interpolation’ to ‘nearest’ and ‘aspect’ to equal."

So while matshow always uses interpolation="nearest", imshow by default has interpolation=None. Note that this is different from interpolation="none".

  • interpolation=None uses the interpolation set in the image.interpolation variable from the matplotlib rc file (which can be different in different matplotlib versions.)
  • interpolation="none" uses no interpolation, same as "nearest"

The safest way to overcome this problem is to specifically set an interpolation method in both calls

plt.matshow(array, interpolation="none")plt.imshow(array, interpolation="none")