gpt4 book ai didi

python - 有没有办法在 matplotlib 中绘制表情符号?

转载 作者:行者123 更新时间:2023-12-03 11:11:54 25 4
gpt4 key购买 nike

有人知道如何在使用 windows 时在 matplotlib 中绘制表情符号吗?我一直在努力寻找解决方案,因为大多数似乎都是针对 macOS 的。

下面是我当前的图表,显示了在向量空间中绘制的表情符号,但像往常一样,大多数都没有出现。

o

matplotlib 是否已经安装了任何提供表情符号支持的字体,或者我是否需要安装一些后端解决方案?

代码:

def display_pca_scatterplot(model, words=None, sample=0):
if words == None:
if sample > 0:
words = np.random.choice(list(model.vocab.keys()), sample)
else:
words = [ word for word in model.vocab ]

prop = FontProperties(fname='/usr/share/fonts/truetype/noto/Apple Color Emoji.ttc')

word_vectors = np.array([model[w] for w in words])

twodim = PCA().fit_transform(word_vectors)[:,:2]

sb.set_style("darkgrid")
plt.figure(figsize=(10,10))
plt.scatter(twodim[:,0], twodim[:,1]) #, edgecolors='w', color='w')
for word, (x,y) in zip(words, twodim):
plt.text(x+0.0, y+0.0, word, fontsize=20) #fontproperties=prop)

最佳答案

这似乎对我有用,但显然取决于安装的默认字体(例如“Segoe UI Emoji”):

plt.text(0,.5,'😀 😃 😄 😁 😆 😅 😂 🤣 ☺️ 😊 😇',fontsize=20)

enter image description here

关于python - 有没有办法在 matplotlib 中绘制表情符号?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/61701600/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com