import matplotlib.pyplot as plt
import matplotlib as mpl
mpl.rcParams['font.family'] = 'sans-serif'
mpl.rcParams['font.sans-serif'] = ['SimHei']
labels = ['没必要', '1','2','3','非常需要']
sizes = [4/59, 5/59,7/59,15/59,28/59]
colors = ['lightgreen','gray', 'gold', 'lightskyblue', 'lightcoral']
plt.pie(sizes, labels=labels, colors=colors, autopct='%1.1f%%', startangle=90)
plt.axis('equal')
plt.show()
import matplotlib.pyplot as plt
plt.rcParams['font.family'] = 'sans-serif'
plt.rcParams['font.sans-serif'] = ['SimHei']
values = [51, 30, 18, 12, 6]
labels = ['数据安全性', '文献准确性', '易操作性', '界面的美观性','其它']
plt.bar(range(len(values)), values, tick_label=labels)
plt.title('影响因素')
plt.xlabel('因素')
plt.ylabel('人数')
plt.xticks(range(len(values)), labels, rotation=0)
plt.show()
import matplotlib.pyplot as plt
plt.rcParams['font.family'] = 'sans-serif'
plt.rcParams['font.sans-serif'] = ['SimHei']
values = [20, 35, 30, 25]
labels = ['苹果', '香蕉', '橙子', '梨子']
fig, ax = plt.subplots(figsize=(8, 6))
ax.barh(range(len(values)), values, tick_label=labels)
ax.set_title('水果销售统计')
ax.set_xlabel('销售量')
ax.set_ylabel('水果')
ax.xaxis.grid(True)
ax.set_yticks(range(len(labels)))
ax.set_yticklabels(labels[::-1])
ax.invert_yaxis()
plt.show()