【问题标题】:matplotlib: Humor Sans does not displayed correctly accentsmatplotlib:Humor Sans 无法正确显示重音符号
【发布时间】:2016-10-02 12:16:23
【问题描述】:

如果我选择 Humor Sans,这就是我从 matplotlib 得到的:

所以“DISTÀNCIA”显示为“DIST?NCIA”。与其他字体一起显示效果很好。

代码在这里:

# -*- coding: utf-8 -*-
from matplotlib import pyplot as plt
import numpy as np
from pylab import *

# Estil de còmic XKCD
plt.xkcd()

# Etiquetes
fig = plt.figure()
plt.title("Distància vs velocitat de les carreres d'atletisme")
plt.xlabel('distància')
plt.ylabel('velocitat de l\'atleta (homes)')

# Configuracions
ax = fig.add_subplot(1, 1, 1)
ax.set_xlim([-10, 12000])
ax.set_ylim([-1, 11])
ax.spines['right'].set_color('none')
ax.spines['top'].set_color('none')
ax.get_xaxis().tick_bottom()
ax.get_yaxis().tick_left()


# Noms
plt.annotate('5000m', xy=(5000, 5.6), arrowprops=dict(arrowstyle='->'), xytext=(4500, 4))

# Data
data = np.genfromtxt('taula-fins-10000.csv', delimiter=';', skip_header=1)
event7 = [ [z[0], z[1]] for z in data if z[0] == 5000]
x = [e[0] for e in event7]
y = [e[1] for e in event7]

# Dibuix    
plt.plot(x, y, 'o')
plt.savefig("grafic-amb-nomes-una-prova.png")

字体有问题吗?

【问题讨论】:

  • 运行您的代码时遇到错误UnicodeDecodeError: 'ascii' codec can't decode byte 0xc3 in position 4: ordinal not in range(128)
  • 这是 Arch 发行版特有的问题?

标签: matplotlib fonts archlinux


【解决方案1】:

我知道这是一个老问题,但也许它仍然有用。

不幸的是,您面临的问题取决于 Humor Sans 本身,并且没有简单的解决方案。该字体的制作考虑了美国单词,模仿了 xkcd 漫画中使用的字体。因此,它根本没有重音字母。

我不知道这是否是西班牙语的习惯,但一些印欧语言使用 - 有点难看 - 在无重音字母后加撇号的解决方法: à--->一个'; e ---> e' 等等……

【讨论】:

  • 不,它不符合我的需要。听起来很奇怪,例如 champu' 而不是 champú
猜你喜欢
  • 2014-01-04
  • 1970-01-01
  • 1970-01-01
  • 2021-12-24
  • 1970-01-01
  • 1970-01-01
  • 2018-05-19
  • 1970-01-01
  • 2013-03-12
相关资源
最近更新 更多