Skip to content

Instantly share code, notes, and snippets.

@iktakahiro
Created March 10, 2016 04:40
Show Gist options
  • Select an option

  • Save iktakahiro/aae1624918ac0a139144 to your computer and use it in GitHub Desktop.

Select an option

Save iktakahiro/aae1624918ac0a139144 to your computer and use it in GitHub Desktop.
matplotlib with Japanese font
plt.style.use('ggplot')
from matplotlib.font_manager import FontProperties
from matplotlib import rcParams
# フォントパスを指定 .ttf 形式でないと駄目な模様, 関連:https://github.com/matplotlib/matplotlib/pull/3912
fp = FontProperties(fname='/Library/Fonts/Osaka.ttf', size=14)
# get_name() で 'Osaka' が返ってきています。メソッドの代わりに = 'Osaka' としてもOK
rcParams['font.family'] = fp.get_name()
pp.plot(kind= 'bar', figsize=(12,6), y= ['女[人]','男[人]'], stacked=True)
plt.ylabel("Population")
plt.subplots_adjust(left=0.08,right=0.95,top=0.95,bottom=0.25,wspace=0.15,hspace=0.05)
plt.show()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment