Follow the steps below to set up a machine learning environment. http://qiita.com/mix_dvd/items/29dfb8d47a596b4df36d
Let's test to display the graph using the data of PyData.Okinawa. https://github.com/PyDataOkinawa/meetup001/blob/master/PyData.Okinawa%20Meetup%20001%20opendata%20sample.ipynb
$ git clone https://github.com/PyDataOkinawa/meetup001.git
Launch the Jupyter Notebook, open the notebook named "PyData.Okinawa Meetup 001 opendata sample.ipynb" and run the kernel "Restart & Run all".
Looking at the graph displayed at the bottom, the Japanese part is "□".
Download the font from IPA and install it for matplotlib to improve the above situation.
You can download it from the following page. If you cannot download with the command, please download with a browser. http://ipafont.ipa.go.jp/old/ipafont/download.html
Ubuntu
$ sudo apt install unzip
$ wget -O ipafont.zip http://ipafont.ipa.go.jp/old/ipafont/IPAfont00303.php
$ unzip ipafont.zip
$ mv IPAfont00303/*.ttf .pyenv/versions/anaconda2-4.0.0/lib/python2.7/site-packages/matplotlib/mpl-data/fonts/ttf/
$ rm .cache/matplotlib/fontList.cache
Mac
First, check the location to clear the font cache. Check the location of the font cache with the following code.
python
import matplotlib
from matplotlib import rc
print(matplotlib.get_cachedir())
In my case, it was "/Users/[username]/.matplotlib".
$ cd
$ curl -o ipafont.zip http://ipafont.ipa.go.jp/old/ipafont/IPAfont00303.php
$ unzip ipafont.zip
$ mv IPAfont00303/*.ttf .pyenv/versions/anaconda2-4.0.0/lib/python2.7/site-packages/matplotlib/mpl-data/fonts/ttf/
$ rm .matplotlib/*.cache
Change the following parts.
Change before
font = {'family':'Osaka'}
rc('font', **font)
After change
font = {'family':'IPAGothic'}
rc('font', **font)
By the way, if you do not put the following code somewhere, an error will occur, so it is recommended to put it before the above code.
python
from matplotlib import pyplot
Japanese was displayed safely.
Recommended Posts