在jupyter使用matplotlib绘图时,虽然使用了如下设置,但仍然出现了中文乱码。
plt.rcParams['font.sans-serif'] = ['SimHei']
plt.rcParams['axes.unicode_minus']=False
from matplotlib.font_manager import _rebuild
_rebuild()
import numpy as np
import pandas as pd
import matplotlib.pyplot as plt
plt.rcParams['axes.unicode_minus'] = False
plt.rcParams['font.sans-serif'] = ['SimHei']
data = np.random.randn(100)
df = pd.DataFrame({'长度':data })
df.plot.hist(bins=20)