可以通过 spines 属性来控制 matplotlib 图表的边框。
import matplotlib.pyplot as plt
fig, ax = plt.subplots()
# 绘制示例数据
x = [1, 2, 3, 4, 5]
y = [3, 5, 1, 7, 4]
ax.plot(x, y)
# 隐藏右侧和顶部边框
ax.spines['right'].set_visible(False)
ax.spines['top'].set_visible(False)
plt.show()
