Closed FLYSTEPHEN closed 6 years ago
matplotlib
plt.rcParams['font.sans-serif']=['SimHei']
Some computers like mine may find no 'SimHei' font and raise a UserWarning. We can recommend the readers to try fonts like'Arial Unicode MS'
if they encounter my problem. To see which fonts can be used here, I found a way from the Internet. It means the fonts with larger bytes are more likely to be Chinese fonts:from matplotlib.font_manager import fontManager import os [font.name for font in fontManager.ttflist if os.path.exists(font.fname) and os.stat(font.fname).st_size>1e7] #output: ['AppleMyungjo', 'AppleGothic', 'Arial Unicode MS']
plotly
- plotly now need registration to be used. we can remind the readers to log in here and regenerate an api_key after registration. We also need to add a line:
plotly.tools.set_credentials_file(username='XXX(you own username)', api_key='xxxxxxxxxxxxxxxxxxxx(you own api_key)')
pyecharts
!pip install pyecharts
When install pyecharts, someone may encounter this like me:error: command 'clang' failed with exit status 1
Then I googled and learned it's because of my lack ofxcode command tools
. The problem can be solved with operating!xcode-select --install
in Jupyter. We can add this reminder.
@FLYSTEPHEN THANKS a lot. For question1. thats the reason why I write the Q&A for how to support Chinese character in matplotlib :https://github.com/hupili/python-for-data-and-media-communication-gitbook/blob/master/module-matplotlib.md#how-to-display-chinese-characters-when-using-matplotlib
For question 2 & 3, I need to check again, I will reply you soon.
You are right. I should have read the Q&A. This note can also help us understand the mechanism behind this library.
also add this to relevant places. this is more primitive approach for Mac users to find and choose font
@FLYSTEPHEN About plotly
. This is because I use the plot online method, which requires an account. I just updated the plot.offline method, you can try without creating an account. https://github.com/hupili/python-for-data-and-media-communication-gitbook/blob/master/notes-week-09.md#plotly
matplotlib
plt.rcParams['font.sans-serif']=['SimHei']
Some computers like mine may find no 'SimHei' font and raise a UserWarning. We can recommend the readers to try fonts like'Arial Unicode MS'
if they encounter my problem. To see which fonts can be used here, I found a way from the Internet. It means the fonts with larger bytes are more likely to be Chinese fonts:plotly
pyecharts
!pip install pyecharts
When install pyecharts, someone may encounter this like me:error: command 'clang' failed with exit status 1
Then I googled and learned it's because of my lack ofxcode command tools
. The problem can be solved with operating!xcode-select --install
in Jupyter. We can add this reminder.