I have the following dictionary:
a = {'❤': 10, '👨👩👦👦': 23, '👹': 13, '🙅🏽': 10, '😡': 13}
I want to draw emojis like a bar and draw them on a bar. At first I liked it here (s annotate
), but it looks bad and it does not support some emojis.
import matplotlib.pyplot as plt
ax = plt.subplot(111)
ax.bar(range(1,6), a.values())
for label, x, y in zip(a.keys(), range(1,6), a.values()):
plt.annotate(
label,
xy=(x, y), xytext=(10,10),
textcoords='offset points', ha='right', va='bottom',
bbox=dict(boxstyle='round,pad=0.5', alpha=0),
fontname='Segoe UI Emoji',
fontsize=20)
ax.spines['right'].set_visible(False)
ax.spines['top'].set_visible(False)
ax.set_xticks([])
plt.show()
As I said, it looks bad:
How can I sketch emojis so that they look good with matplotlib?
A better option would be to use a different font in matplotlib that will support these emojis (I tried using several different values for plt.rcParams['font.family']
no success), but if it does not exist, the images will work too (but how?)
I do not want to start web-cleaning images and marking them (because I'm sure someone has already done this).
python 3, ID Spyder, matplotlib 2.0.2 anaconda.
?