I would like to use a font which can display all emojis needed. I have got a dataframe which looks like this:
chars num
0 295
1 ☺ 365
2 401
3 ♥ 426
4 461
5 488
6 499
7 644
8 691
9 ❤ 950
10 1328
I want to plot the number of emojis, while the emojis are in the xticks. I wanted to use this font here: Twemoji Color which I have installed already. I managed to get it working with the title, x_label, y_label but not the x_ticks with this solution.
Tge following code results in this image:
import matplotlib
import matplotlib.pyplot as plt
import matplotlib.font_manager as fm
from matplotlib import ft2font
from matplotlib.font_manager import ttfFontProperty
import pandas as pd
fpath = '/usr/share/fonts/Twitter Color Emoji/TwitterColorEmoji-SVGinOT.ttf'
fprop = fm.FontProperties(fname=fpath)
font = ft2font.FT2Font(fpath)
fprop = fm.FontProperties(fname=fpath)
ttfFontProp = ttfFontProperty(font)
fontprop = fm.FontProperties(family='sans-serif',
fname=ttfFontProp.fname,
size=fontsize,
stretch=ttfFontProp.stretch,
style=ttfFontProp.style,
variant=ttfFontProp.variant,
weight=ttfFontProp.weight)
emojis = ['', '☺', '', '♥', '', '', '', '', '', '❤', '']
nums = [295, 365, 401, 426, 461, 488, 499, 644, 691, 950, 1328]
df = pd.DataFrame({'chars': emojis, 'num': nums})
axis = df.plot.bar()
axis.set_title(' '.join(emojis), fontproperties=prop)
axis.set_xticklabels(df.chars.tolist(), rotation=0, fontsize=5)
plot.show()
Currently I am doing the following:
import matplotlib.pyplot as plt
import pandas as pd
emojis = ['', '☺', '', '♥', '', '', '', '', '', '❤', '']
nums = [295, 365, 401, 426, 461, 488, 499, 644, 691, 950, 1328]
df = pd.DataFrame({'chars': emojis, 'num': nums})
axis = x.plot.bar()
plt.show()
I know now, that I can use axis.set_xticklabels(df.chars.tolist(), rotation=0)
to get the emojis rotated right, but not how to set the font properly.