Skip to content

Cannot render Apple Color Emoji in plots #12830

Description

@brienna

Bug report

In both Jupyter Notebook and Terminal, I cannot display emojis using the Apple Color Emoji font.

If I attempt to set fontname='Apple Color Emoji' matplotlib won't find the font, and falls back to the default font DejaVu Sans, which renders the image below.

download 2

If I try to load the font using font_manager.FontProperties, it throws an error: RuntimeError: In FT2Font: Could not set the fontsize.

Code for reproduction

import matplotlib.pyplot as plt
from matplotlib.font_manager import FontProperties
import numpy as np

prop = FontProperties(fname='/System/Library/Fonts/Apple Color Emoji.ttc')

freqs = [301, 96, 53, 81, 42]
labels = ['😊', '😱', '😂', '😄', '😛']
plt.figure(figsize=(12,8))
p1 = plt.bar(np.arange(len(labels)), freqs, 0.8, color="lightblue")
new_ylim = plt.ylim()[1]+30
plt.ylim(0, new_ylim)

# 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',
        #fontname='Apple Color Emoji'
        fontproperties = prop
    )
    
plt.show()

Matplotlib version

  • Operating system: MacOS Sierra 10.12.6
  • Matplotlib version: 2.2.3
  • Matplotlib backend: MacOSX and module://ipykernel.pylab.backend_inline
  • Python version: Python 3.7.0
  • Jupyter version (if applicable): 5.6.0

Related StackOverflow question.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

keepItems to be ignored by the “Stale” Github Actiontopic: text/fonts

Type

No type

Projects

Relationships

None yet

Development

No branches or pull requests

Issue actions