小编arn*_*ldo的帖子

强制matplotlibrc使用Arial(字体路径)

我的系统中安装了Arial字体:

/usr/share/fonts/truetype/msttcorefonts/Arial_Bold_Italic.ttf
/usr/share/fonts/truetype/msttcorefonts/arialbi.ttf
/usr/share/fonts/truetype/msttcorefonts/Arial_Bold.ttf
/usr/share/fonts/truetype/msttcorefonts/arial.ttf
/usr/share/fonts/truetype/msttcorefonts/ariali.ttf
/usr/share/fonts/truetype/msttcorefonts/arialbd.ttf
/usr/share/fonts/truetype/msttcorefonts/Arial.ttf
/usr/share/fonts/truetype/msttcorefonts/Arial_Italic.ttf
/usr/share/fonts/truetype/msttcorefonts/Arial_Black.ttf
/usr/share/xbmc/media/Fonts/arial.ttf
/usr/local/share/texmf/fonts/tfm/urw/arial
/usr/local/share/texmf/fonts/afm/urw/arial
/usr/local/share/texmf/fonts/vf/urw/arial
/usr/local/share/texmf/fonts/type1/urw/arial
Run Code Online (Sandbox Code Playgroud)

我在matplotlibrc里面改了一行,包括:

font.sans-serif      : Arial
Run Code Online (Sandbox Code Playgroud)

如果我在IPython中检查:

import matplotlib.pyplot as plt
plt.plot([1,2,3,4,5,], '*')
t = plt.ylabel(r'1, 2, 3, 8, 9 6 11 Testing Label')
print(t.get_fontname())
Run Code Online (Sandbox Code Playgroud)

输出是:

myhome/local/lib/python2.7/site-packages/matplotlib-1.4.2-py2.7-linux-
x86_64.egg/matplotlib/font_manager.py:1279: UserWarning: findfont: Font
family [u'sans-serif'] not found. Falling back to Bitstream Vera Sans
(prop.get_family(), self.defaultFamily[fontext]))

Bitstream Vera Sans
Run Code Online (Sandbox Code Playgroud)

如何更改此行为并为我的所有绘图使用Arial字体?为什么没有加载Arial字体?

有趣的是,如果我使用Seaborn,它会返回Liberation Sans第一个字体(内部字体列表内部)为Arial,第二个字体为Arial Liberation Sans.

matplotlib python-2.7 seaborn

7
推荐指数
1
解决办法
4556
查看次数

svgwrite - 如何启用将其他对象写入/添加为现有.svg文件的层

我有一个svg文件,我想在这个存在中插入其他svg对象.

import svgwrite

dwg = svgwrite.Drawing('model.svg')
square = dwg.add(dwg.rect(20,20),(80,80), fill='blue'))
dwg.save()
Run Code Online (Sandbox Code Playgroud)

它返回一个具有此形状的新文件,忽略我之前的文件.我怎么写这个?

谢谢

python svg

3
推荐指数
1
解决办法
2073
查看次数

标签 统计

matplotlib ×1

python ×1

python-2.7 ×1

seaborn ×1

svg ×1