matplotlib:幽默Sans不能正确显示口音 [英] matplotlib: Humor Sans does not displayed correctly accents

查看:135
本文介绍了matplotlib:幽默Sans不能正确显示口音的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如果我选择Humor Sans,这就是我从matplotlib中获得的信息:

This is what I get from matplotlib if I choose Humor Sans:

因此DISTÀNCIA"显示为"DIST?NCIA".与其他字体一起很好地显示.

So "DISTÀNCIA" showed as "DIST?NCIA". It is well-displayed with other font.

代码在这里:

# -*- 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")

字体有问题吗?

推荐答案

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

I know this is an old question, but maybe it can still be useful.

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

Unfortunately, the problem you are facing depends on Humor Sans itself, and has no easy solution. The font was made having US words in mind, mimicking the one used on xkcd comic strips. For this reason, it comes with no accented letters at all.

我不知道这是否是西班牙语的习惯,但是一些印度洋语言使用-有点丑陋的解决方法,将无引号后面加上撇号: à---> a'; é---> e' 等等...

I don't know if it's customary in spanish, but some indoeuropean languages use the -somewhat ugly- workaround of putting an apostrophe after the unaccented letter: à ---> a'; é ---> e' and so on...

这篇关于matplotlib:幽默Sans不能正确显示口音的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆