0
Talk personal. I have a problem using the Matplotlib library. Before the last Windows update I used the library without any problem. I basically use it to create function charts and save them on. pdf using Latex formatting for the text, below follows a code as an example:
import numpy as np
from matplotlib import pyplot as plt
# Data for plot
step = 0.001
x = np.arange(0, 2 + step, step)
y = x*x*np.cos(10*x)
plt.rc('text', usetex=True)
plt.rc('font', family='serif')
plt.figure(figsize=(19.2, 10.8))
plt.plot(x, y, lw=2)
plt.title(r'Function $f(x) = x^2 \cos(10x)$')
plt.savefig('plot.pdf', bbox_inches='tight')
plt.show()
plt.close()
However after the update my old windows bugged and I was forced to format the pc, and now I can’t use the same code above and save the figures in . pdf, the following error happens:
File "C:\ProgramData\Anaconda3\lib\site-packages\matplotlib\dviread.py", line 1057, in find_tex_file
return result.decode('ascii')
UnicodeDecodeError: 'ascii' codec can't decode byte 0xc3 in position 10: ordinal not in range(128)
Using the same code I am able to save in other formats, for example . png and .eps. After formatting I basically installed the same software I used before.
Ps. The above code has been tested on Spyder 3.2.6 and Pycharm 2018.1.3 with Python version 3.6.4. Latex is working perfectly. I use Miktex for Latex base and Texstudio editor.
Unfortunately an extra space came out in the eighth line of the code. Disregard.
– Fábio Nascentes