【发布时间】:2017-09-11 04:31:57
【问题描述】:
我在 macOS 中使用 Python 3.4。 Matplotlib 应该支持标签中的 Unicode,但我没有看到 Emojis 正确呈现。
import matplotlib.pyplot as plt
# some code to generate `data` and `labels`...
plt.clf()
plt.scatter(data[:, 0], data[:, 1], c=col)
# disclaimer: labeling taken from example http://stackoverflow.com/questions/5147112/matplotlib-how-to-put-individual-tags-for-a-scatter-plot
for label, x, y in zip(labels, data[:, 0], data[:, 1]):
plt.annotate(
label, # some of these contain Emojis
xy=(x, y), xytext=(-20, 20),
textcoords='offset points', ha='right', va='bottom',
bbox=dict(boxstyle='round,pad=0.5', fc='yellow', alpha=0.5),
arrowprops=dict(arrowstyle = '->', connectionstyle='arc3,rad=0'))
plt.show(False)
一些旧的 Unicode 之前的表情符号以其旧样式出现,但其余的(在本例中为“火”、“音乐”等)没有。有什么技巧可以让这些正确显示吗?
【问题讨论】:
标签: python-3.x matplotlib