1. 程式人生 > >Jupyter notebook畫圖中文顯示亂碼,靠譜的解決辦法

Jupyter notebook畫圖中文顯示亂碼,靠譜的解決辦法

在Jupyter notebook畫圖前,加入以下程式碼:

import matplotlib
matplotlib.use('qt4agg')
#指定預設字型
matplotlib.rcParams['font.sans-serif'] = ['SimHei']
matplotlib.rcParams['font.family']='sans-serif'
#解決負號'-'顯示為方塊的問題
matplotlib.rcParams['axes.unicode_minus'] = False

歡迎關注微信公眾號“資料分析師手記”
這裡寫圖片描述