Skip to content

Instantly share code, notes, and snippets.

@moskomule
Created May 14, 2017 08:04
Show Gist options
  • Save moskomule/a706c41f87b4e180e14cd3f6058c9bfb to your computer and use it in GitHub Desktop.
Save moskomule/a706c41f87b4e180e14cd3f6058c9bfb to your computer and use it in GitHub Desktop.
settings of Japanese characters in matplotlib figures
import matplotlib
import os
# style setting
matplotlib.style.use('seaborn-white')
# font setting
fp = matplotlib.font_manager.FontProperties(fname=os.path.expanduser('~/Library/Fonts/ipaexg.ttf'))
plt.rcParams['font.family'] = fp.get_name()
plt.plot(0, 1)
plt.text(0, 1, "こんにちは世界")
plt.show()
# if characters are like ▢▢, delete `~/.matplotlib`
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment