python matplotlib画图不显示中文解决办法

 

解决办法

font = {
    'family':'SimHei',
    'weight':'bold',
    'size':'16'
}
matplotlib.rc("font",**font)



import random

from matplotlib import pyplot as plt
from sympy.physics.quantum.circuitplot import matplotlib

font = {
    'family':'SimHei',
    'weight':'bold',
    'size':'16'
}
matplotlib.rc("font",**font)



x = range(0,120)
y = [random.randint(20,35) for i in range(0,120)]

plt.figure(figsize=(20,10),dpi=80)
plt.plot(x,y)
# 调整X轴刻度
_x = list(x)
_xtick_labels = ["10点{}分".format(i) for i in range(60)]
_xtick_labels += ["11点{}分".format(i) for i in range(60)]

plt.xticks(_x[::3],_xtick_labels[::3],rotation=90)


plt.show()

 

你可能感兴趣的:(matplotlib)