问题
This is what I get from matplotlib if I choose Humor Sans:
So "DISTÀNCIA" showed as "DIST?NCIA". It is well-displayed with other font.
The code is here:
# -*- 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")
Is it a problem with the font?
回答1:
I know this is an old question, but maybe it can still be useful.
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.
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...
来源:https://stackoverflow.com/questions/39816904/matplotlib-humor-sans-does-not-displayed-correctly-accents