matplotlib
在Jupyter笔记本里。我也在终端测试过。
代码:
freqs = [90, 29, 5, 29, 15]
labels = [ð
, ð, ð, ð, ð]
# Plot the figure
plt.figure(figsize=(12, 8))
ax = pd.Series(freqs).plot(kind='bar', color='pink', width=0.8)
ax.set_title('Most Frequently Used Emojis')
ax.set_ylabel('Frequency', fontsize=15)
ax.set_xlabel('Emojis', fontsize=15)
plt.tick_params(
axis='x',
which='both',
bottom=False,
top=False,
labelbottom=False
)
new_ylim = ax.get_ylim()[1]+30
ax.set_ylim((0, new_ylim))
rects = ax.patches
# Make labels
for rect, label in zip(rects, labels):
height = rect.get_height()
plt.annotate(
label,
(rect.get_x() + rect.get_width()/2, height+5),
ha="center",
va="bottom",
fontsize=30
)
plt.show()
添加后
import matplotlib.font_manager as mfm
emoji_font = mfm.FontProperties(fname="/System/Library/Fonts/Apple Color Emoji.ttc")
和
fontproperties = emoji_font
作为一个选项
plt.annotate
RuntimeError: In FT2Font: Could not set the fontsize
. 这个数字不会显示。
我怎样才能让表情符号显示在Jupyter笔记本的条形图中?
如果我使用Symbola这样的字体,emojis看起来会像这样:
我不想要这些表情符号。我也不想加载图像。它们应该是真正的苹果表情符号。
其他尚未回答或使用上述错误表情符号回答的问题:
他们中没有人能把苹果的表情画在图表上。为什么不能这样?我遗漏了什么吗?是否可以使用另一个绘图库?