I have been trying to save an imshow figure as a PDF, but when I try to open it up in my PDF reader (Acrobat Reader DC) it says "Insufficient data for an image" and refuses to display the image. Furthermore, if I open it in Google Chrome instead, I get an image, but it looks different from what it is supposed to. I use Spyder on a Windows computer, but I noticed that if I run the same code in the terminal, it works fine.
Here is an example:
plt.figure()
plt.imshow([[1,4,6],[6,7,8]])
plt.savefig("testplot.pdf")
plt.show()
This yields the following image in Spyder (the plt.imshow, not the saved image):

The saved image when opened in Google Chrome looks like this:

I use plt.savefig here, but I also tried plt.imsave, and in that case I can't even see it in Google Chrome.