over 5 years ago

## Matplotlib display Chinese characters

When I was trying to use Chinese characters for a chart's title, matplotlib displayed a bunch of squares. Here are the steps to solve it.

##### Step 1: Find matplotlibrc

I am using virtualenv, so for me the path is:

~/.envs/edge/lib/python3.5/site-packages/matplotlib/mpl-data

The key part is /lib/python3.5/site-packages/matplotlib/mpl-data

##### Step 2: Modify matplotlibrc

Uncomment font.family and font.sans-serif, then add the following fonts before Bitstream Vera Sans:

PingFang SC, Hiragino Sans GB, Microsoft YaHei,

It should look like this:

If you have a ipyton notebook open, you have to close and reopen it to make this change effective. Otherwise this is it :D