{"cells":[{"cell_type":"markdown","metadata":{"id":"rU_od4vgJayo"},"source":["# matplotlib 入門 (3) nitta@tsuda.ac.jp\n","\n","# 3章: 日本語フォントの利用\n","\n","
plt.rcParams['font.family'] = 'IPAexGothic'
を指定する。matplotlib.get_cachedir()
で調べる。\n","消すべきなのはそのフォルダの中の fontlist-vXXX.json ファイルなのだが、面倒なので今回はフォルダごと消してしまう。"]},{"cell_type":"code","execution_count":6,"metadata":{"colab":{"base_uri":"https://localhost:8080/"},"executionInfo":{"elapsed":641,"status":"ok","timestamp":1657424968942,"user":{"displayName":"Yoshihisa Nitta","userId":"15888006800030996813"},"user_tz":-540},"id":"dxwECA8Gk2eX","outputId":"62250ad4-d52b-47b4-f96a-502b93871d54"},"outputs":[{"output_type":"stream","name":"stdout","text":["/root/.cache/matplotlib\n","total 44\n","drwxr-xr-x 3 root root 4096 Jul 6 13:32 .\n","drwxr-xr-x 1 root root 4096 Jul 7 13:19 ..\n","-rw-r--r-- 1 root root 29337 Jul 6 13:32 fontlist-v310.json\n","drwxr-xr-x 2 root root 4096 Jul 6 13:32 tex.cache\n"]}],"source":["# font cache path\n","import matplotlib\n","cache_path = matplotlib.get_cachedir()\n","print(cache_path)\n","\n","! {LS_L} {cache_path}\n","! {RM_RF} {cache_path}"]},{"cell_type":"markdown","metadata":{"id":"_aCpnNW6lr0q"},"source":["Windows や Mac の Anaconda で jupyter を動作させている場合は、フォントキャッシュはmatplotlib.get_configdir()
の下の\n","fontlist-vXXX.json である。"]},{"cell_type":"markdown","metadata":{"id":"UuraWMOJj8Vn"},"source":["## 3-4: runtime を再起動する\n","\n","Google Colab の場合:\n","ランタイム → ランタイムを再起動\n","\n","手元のPCで jupyter notebook を走らせている場合:\n","Kernel → Restart"]},{"cell_type":"markdown","metadata":{"id":"RqCGTqiqhbIB"},"source":["## 3-5: font.family を指定して matplotlib を利用する。\n","\n","runtime を再起動した後、直ちに次のセルを実行する。"]},{"cell_type":"code","execution_count":1,"metadata":{"colab":{"base_uri":"https://localhost:8080/","height":401},"executionInfo":{"elapsed":8,"status":"ok","timestamp":1657425010905,"user":{"displayName":"Yoshihisa Nitta","userId":"15888006800030996813"},"user_tz":-540},"id":"IDDZnE9DN_30","outputId":"b1b948b2-4bf1-4655-aeee-1b9cba2566a7"},"outputs":[{"output_type":"display_data","data":{"text/plain":["