Created
January 23, 2019 18:53
-
-
Save brienna/edca0a6e5eea8b057190231ec855872b to your computer and use it in GitHub Desktop.
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
# Set the backend to use mplcairo | |
import matplotlib, mplcairo | |
print('Default backend: ' + matplotlib.get_backend()) | |
matplotlib.use("module://mplcairo.macosx") | |
print('Backend is now ' + matplotlib.get_backend()) | |
# IMPORTANT: Import these libraries only AFTER setting the backend | |
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() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment