import matplotlib.pyplot as plt
import matplotlib as mpl
import pandas as pd
mpl.rcParams['font.family'] = 'sans-serif'
mpl.rcParams['font.sans-serif'] = ['SimHei']
mpl.rcParams['axes.unicode_minus'] = False
print(mpl.matplotlib_fname())
df1 = pd.DataFrame({
u'计算机应用基础': [85, 78, 81, 95, 70, 67, 82, 72, 80, 81, 77],
u'西方经济学': [93, 81, 76, 88, 66, 79, 83, 92, 78, 86, 78],
u'数学': [65, 95, 51, 74, 78, 63, 91, 82, 75, 71, 55],
u'英语': [76, 90, 97, 71, 70, 93, 86, 83, 78, 85, 81],
})
print(df1)
# plt.style.use('ggplot') # 样式
plt.boxplot(x=df1.values, labels=df1.columns, whis=1.5, patch_artist=True, showmeans=True)
# plt.ylim(0, 85) # y轴范围
plt.show()
结果展示