Last active
April 12, 2024 11:20
-
-
Save brienna/3433fdfdca2c7ba7b008381410af8e2f to your computer and use it in GitHub Desktop.
Plotting emojis with Matplotlib
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import matplotlib.pyplot as plt, numpy as np | |
from matplotlib.font_manager import FontProperties | |
# Load Apple Color Emoji font | |
prop = FontProperties(fname='/System/Library/Fonts/Apple Color Emoji.ttc') | |
# Set up plot | |
freqs = [301, 96, 53, 81, 42] | |
labels = ['๐', '๐ฑ', '๐', '๐', '๐'] | |
plt.figure(figsize=(12,8)) | |
p1 = plt.bar(np.arange(len(labels)), freqs, 0.8, color="lightblue") | |
plt.ylim(0, plt.ylim()[1]+30) | |
# Make labels | |
for rect1, label in zip(p1, labels): | |
height = rect1.get_height() | |
plt.annotate( | |
label, | |
(rect1.get_x() + rect1.get_width()/2, height+5), | |
ha="center", | |
va="bottom", | |
fontsize=30, | |
fontproperties=prop | |
) | |
plt.show() |
Same here... Thanks for the suggestion anyways, hopefully I'll get it to work..
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Hello, this doesn't work for me I get "RuntimeError: In FT2Font: Could not set the fontsize (error code 0x17)"