[英]Enthought - matplotlib (problems with plot() function)
I am trying to use matplotlib on Canopy Express. 我想在Canopy Express上使用matplotlib 。 Even simple code does not run...
即使是简单的代码也不会运行......
NOTE: the system does not recognize the plot(x)
function. 注意:系统无法识别
plot(x)
功能。 It seems there is something with ASCII X Unicode. 似乎有一些ASCII X Unicode。 My computer uses Unicode English(US).
我的电脑使用Unicode英语(美国)。
From the console we have: 从控制台我们有:
C:\Users\dafonseca\AppData\Local\Enthought\Canopy\User\lib\site-packages\matplotlib\font_manager.py in createFontList(fontfiles, fontext)
582 continue
583 try:
--> 584 prop = ttfFontProperty(font)
585 except KeyError:
586 continue
C:\Users\dafonseca\AppData\Local\Enthought\Canopy\User\lib\site-packages\matplotlib\font_manager.py in ttfFontProperty(font)
396 sfnt2 = ''
397 if sfnt4:
--> 398 sfnt4 = sfnt4.decode('ascii').lower()
399 else:
400 sfnt4 = ''
UnicodeDecodeError: 'ascii' codec can't decode byte 0x82 in position 0: ordinal not in range(128)'
import numpy as np
import matplotlib.pyplot as plt
x = np.linspace(0, 10)
line, = plt.plot(x, np.sin(x), '--', linewidth=2)
dashes = [10, 5, 100, 5] # 10 points on, 5 off, 100 on, 5 off
line.set_dashes(dashes)
plt.show()
This is a known issue in matplotlib 1.3.0 that relates to having a non-ASCII character in one of your font names (possibly the Æ
character). 这是matplotlib 1.3.0中的一个已知问题 ,它涉及在您的一个字体名称(可能是
Æ
字符)中包含非ASCII字符。
You can either find and remove the offending font (the best idea) or try to patch your installation using the following procedure: 您可以找到并删除有问题的字体(最好的主意),也可以尝试使用以下过程修补安装:
Open the following in a text editor: 在文本编辑器中打开以下内容:
\\Users\\dafonseca\\AppData\\Local\\Enthought\\Canopy\\User\\lib\\site- packages\\matplotlib\\font_manager.py
Search for sfnt4 = sfnt4.decode('ascii').lower()
搜索
sfnt4 = sfnt4.decode('ascii').lower()
And replace with sfnt4 = sfnt4.decode('ascii', 'ignore').lower()
并替换为
sfnt4 = sfnt4.decode('ascii', 'ignore').lower()
Note that this bug won't exist in the next release of matplotlib. 请注意,matplotlib的下一个版本中不会存在此错误。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.