ax.grid(
which='both', # 'major'|'minor'|'both'
axis='both', # 'x'|'y'|'both'
linewidth=1,
linestyle='-',
color='red',
alpha=0.1
)

代码必须放在最后,否则出现交叉点重叠

import numpy as np
import matplotlib.pyplot as plt

fig = plt.figure()


ax = fig.add_subplot(111)
ax.tick_params(left=False,labelleft=False,top=False,bottom=False,labelbottom=False,labeltop=False,right=True,labelright = True)
plt.title("xxxxxxxxxx")
plt.xlabel("Param drop(%)")
plt.ylabel("Accuracy(%)")

ax.tick_params("both",which ='both', length=5, width=1.0, labelsize=10, labelcolor='0.6', direction='in')




ax.set_ylim(0, 100)
ax.set_xlim(0, 10)
axt = ax.twinx()
axt.set_ylim(0,100)

x1 = [1,2,3,4,5,6,7,8]
y1 = [20,100,50,120,55,100,50,25]
x2 = [3,4,5,6,7,8,9]
y2 = [25,35,14,67,88,44,120]

ax.plot(x1, y1, color='lightblue',linewidth=2)
ax.plot(x2, y2, color='darkgreen', marker='^')


# Plot the cross point
x3 = np.linspace(6, 7, 1000) # (6, 7) intersection range
y1_new = np.linspace(240, 50, 1000) # (6, 7) corresponding to (240, 50) in y1
y2_new = np.linspace(67, 88, 1000) # (6, 7) corresponding to (67, 88) in y2

idx = np.argwhere(np.isclose(y1_new, y2_new, atol=0.1)).reshape(-1)
ax.plot(x3[idx], y2_new[idx], 'r*',)
ax.text(x3[idx], y2_new[idx]-5, '%.0f' % y2_new[idx],fontdict={'fontsize':14})


ax.grid(
which='both', # 'major'|'minor'|'both'
axis='both', # 'x'|'y'|'both'
linewidth=1,
linestyle='-',
color='red',
alpha=0.1
)

plt.show()