plt.yticks( size=15,weight='bold')#设置大小及加粗
plt.xticks(size=20,weight='bold')
plt.xlabel('is_or_non_native',fontsize=20,fontweight='bold') # x_label
plt.ylabel('percentage',fontsize=20,fontweight='bold') # y_label
import matplotlib.pyplot as plt
import numpy as np
#交通出行方式
x_axis_data = ['walk', 'bicycle ', 'bus', 'car', 'subway'] # x
y_axis_data_201910_per = [0.0855 , 0.0480 ,0.1269 ,0.0568 , 0.6828] # y
y_axis_data_202010_per= [0.1547 , 0.0695 ,0.1444 ,0.0589 , 0.5726] # y
y_axis_data_202106_per= [0.1582 , 0.0540 ,0.1618 ,0.0619 , 0.5641] # y
y_axis_data_201910 = [37226,20907,55288,24731,297396] # y
y_axis_data_202010= [70920,31854,66203,27006,262518] # y
y_axis_data_202106= [43791,14945,44789,17123,156151] # y
fig, ax1 = plt.subplots()
ax2 = ax1.twinx()
ax1.plot(x_axis_data, y_axis_data_201910_per, 'ws--', alpha=0.6, linewidth=2)
ax1.plot(x_axis_data, y_axis_data_202010_per, 'ws--', alpha=0.6, linewidth=2)
ax1.plot(x_axis_data, y_axis_data_202106_per, 'ws--', alpha=0.6, linewidth=2)
ax2.plot(x_axis_data, y_axis_data_201910, color='#4874B2', marker='s', linestyle='--', alpha=1, linewidth=4,
label='201910')
ax2.plot(x_axis_data, y_axis_data_202010, color='#DB4924', marker='s', linestyle='--', alpha=1, linewidth=4,
label='202010')
ax2.plot(x_axis_data, y_axis_data_202106, color='#FFDF92', marker='s', linestyle='--', alpha=1, linewidth=4,
label='202106')
# plt.legend() # 显示上面的label
plt.yticks( size=15)#设置大小及加粗
plt.xticks(size=20)
plt.xlabel('transportation',fontsize=20) # x_label
plt.ylabel('percentage',fontsize=20) # y_label
plt.show()
# -*- coding:utf-8 -*-
import matplotlib
import matplotlib.pyplot as plt
import numpy as np
matplotlib.rcParams['font.sans-serif'] = ['SimHei'] # 用黑体显示中文
# 构建数据
x = np.arange(1, 15)
y = [0.8, 0.88, 0.825, 0.76, 0.91, 0.95, 0.74, 0.99, 0.80, 0.72, 0.9, 0.81, 0.74, 0.87]
z = [37, 25, 17, 49, 27, 77, 34, 34, 34, 51, 39, 52, 47, 12]
u = [37, 31, 19, 57, 29, 86, 36, 37, 45, 64, 42, 57, 50, 24]
# 绘柱状图
plt.bar(x=x, height=z, label='实际', color='Coral', alpha=0.8)
plt.bar(x=x, height=u, label='总数', color='LemonChiffon', alpha=0.8)
# 在左侧显示图例
plt.legend(loc="upper left")
# 设置标题
plt.title("Detection results")
# 为两条坐标轴设置名称
plt.xlabel("Component number")
plt.ylabel("Number of seam")
# 画折线图
ax2 = plt.twinx()
ax2.set_ylabel("recall")
# 设置坐标轴范围
ax2.set_ylim([0.5, 1.05]);
plt.plot(x, y, "r", marker='.', c='r', ms=5, linewidth='1', label="Recall")
# 显示数字
for a, b in zip(x, y):
plt.text(a, b, b, ha='center', va='bottom', fontsize=8)
# 在右侧显示图例
plt.legend(loc="upper right")
plt.savefig("recall.jpg")
plt.show()