Bug summary
I have a pcolormesh that has shading='gouraud', and I am trying to save it to an .eps. If I save the image as .png everything works fine, but when I save it as .eps it gives error. A similar issue was already open and then closed in the past.
Code for reproduction
import matplotlib.pyplot as plt
import numpy as np
plt.pcolormesh(np.random.randn(10,10), shading='gouraud')
plt.gcf().savefig('test.eps')
Matplotlib version
matplotlib 3.1.1
Python 3.6.8 |Anaconda custom (64-bit)| (default, Feb 21 2019, 18:30:04) [MSC v.1916 64 bit (AMD64)]
I provide an example. The first figure (etaGainH.png) is the one I save from python with plt.savefig('etaGainH.png'). The second figure is the one I get when I use plt.savefig('etaGainH.eps').
works fine. However, when I save the image with .eps, some pixels change. You can see the difference in my second post. This problem does not exist when I use shading='flat' or when I save the image as .png.
If you compare the image TestGou.png and TestGou-eps-converted-to.pdf, they are different. On the other hand, TestFlat-eps-converted-to.pdf and TestFlat.png are identical.
I would like to know where I'm doing something wrong. Thank you in advance for your help.
Activity
lclanzi commented on Jan 14, 2020
I provide an example. The first figure (etaGainH.png) is the one I save from python with plt.savefig('etaGainH.png'). The second figure is the one I get when I use plt.savefig('etaGainH.eps').
etaGainH-eps-converted-to.pdf
This is the code I'm using:
Note that if I use shading='flat' instead of shading='gouraud', this is what I get
etaGainHFlat-eps-converted-to.pdf
Code
The problem seems to be related to this particular shading option.
Hope that the issue is more clear.
anntzer commented on Jan 14, 2020
Locally this works for me, and #1993 suggests that it indeed should.
lclanzi commented on Jan 14, 2020
Hi, thank you for your reply.
I did not explain well what the problem is in the first post.
The code
works fine. However, when I save the image with .eps, some pixels change. You can see the difference in my second post. This problem does not exist when I use shading='flat' or when I save the image as .png.
anntzer commented on Jan 14, 2020
Your example is not reproducible: we don't have the hstar, invparam variables.
lclanzi commented on Jan 14, 2020
I'm sorry, you are right.
Here it is a reproducible example.
For images with shading='gouraud':
Output:

TestGou-eps-converted-to.pdf
For images with shading='flat':
Output:

TestFlat-eps-converted-to.pdf
If you compare the image TestGou.png and TestGou-eps-converted-to.pdf, they are different. On the other hand, TestFlat-eps-converted-to.pdf and TestFlat.png are identical.
I would like to know where I'm doing something wrong. Thank you in advance for your help.
anntzer commented on Jan 14, 2020
Yes, I can confirm the difference now.
QuLogic commented on Apr 21, 2023
I'm not sure of the exact portion of the change that did it, but this was fixed by #23294.