You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
For hashtags containing emojis (such as #ukraine🇺🇦), the plot generated by hashtag_frequencies.plot does not display the emoji, as shown in the figure below.
The problem seems to be that the default matplotlib font can't handle non-ASCII characters.
One option would be using a different font, but I doubt there's any single font installed by default on all operating systems (Windows, macOS, Linux) that we could specify.
One way around this is to specify a font for each operating system, e.g.
from sys import platform
...
if platform == 'win32':
font_path = <WINDOWS SYSTEM FONT THAT SUPPORTS EMOJIS>.otf
elif platform == 'darwin':
font_path = <MACOS SYSTEM FONT THAT SUPPORTS EMOJIS>.otf
elif platform in ('linux', 'linux2'):
font_path = <LINUX/UBUNTU SYSTEM FONT THAT SUPPORTS EMOJIS>.otf
else:
USE DEFAULT FONT
font_manager.fontManager.addfont(font_path)
prop = font_manager.FontProperties(fname=font_path)
plt.rcParams['font.family'] = 'sans-serif'
plt.rcParams['font.sans-serif'] = prop.get_name()
Another option could be using a package like mplcairo.
For hashtags containing emojis (such as #ukraine🇺🇦), the plot generated by
hashtag_frequencies.plot
does not display the emoji, as shown in the figure below.The problem seems to be that the default matplotlib font can't handle non-ASCII characters.
One option would be using a different font, but I doubt there's any single font installed by default on all operating systems (Windows, macOS, Linux) that we could specify.
One way around this is to specify a font for each operating system, e.g.
Another option could be using a package like mplcairo.
see the following links for reference:
The text was updated successfully, but these errors were encountered: