You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
the following script works fine on python 2.7.8, however it produces a non valid eps file on python 3.4.1.
import numpy as np
import matplotlib
from matplotlib import pyplot as plt
if __name__ == "__main__":
print ("Using matplotlib v%s" %matplotlib.__version__)
x = np.linspace(0, 10)
y = np.sin(x)
plt.figure()
plt.plot(x, y)
plt.savefig("out.eps", format='eps')
plt.show()
The two attachements following are the two outputs generated by python2 and python3 respectively (I changed the file extension to png to be able to upload them, but they are indeed eps files).
With a diff of the two files, and some manual editing, I found that the line responsible for the malfunctioning is the following
Activity
tacaswell commentedon Sep 10, 2014
what version of mpl are you using?
tacaswell commentedon Sep 10, 2014
It looks like another str vs byte issue
The obvious source of the bug is here https://github.com/matplotlib/matplotlib/blob/master/lib/matplotlib/backends/backend_ps.py#L291 where it is trying to format a byte string into a normal string and we pick up the extra
b''(this is the same issue as the blank-screen issue fixed in #3464 ), but I suspect that what ever is calling this should be passing in a real string, not bytes.tacaswell commentedon Sep 10, 2014
https://github.com/matplotlib/matplotlib/blob/master/lib/matplotlib/backends/backend_ps.py#L767
is the real source of the problem which explicitly turns the font name into bytes with encode, which I suspect was done to strip out non-ascii characters that eps does not support.
BUG : fix str vs bytes issue in py3 in ps backend
japs commentedon Sep 10, 2014
sorry, i forgot the most basic information, i'm running matplotlib 1.3.1