matplotlib给坐标轴两端加上箭头并设置箭头粗细
可以使用arrowstyle参数设置箭头样式,使用linewidth参数设置箭头粗细。例如:
import matplotlib.pyplot as plt
fig, ax = plt.subplots()
ax.plot([0, 1], [0, 1])
ax.spines['right'].set_visible(False)
ax.spines['top'].set_visible(False)
ax.spines['left'].set_linewidth(2)
ax.spines['bottom'].set_linewidth(2)
ax.spines['left'].set_arrowstyle('->', linewidth=2)
ax.spines['bottom'].set_arrowstyle('->', linewidth=2)
plt.show()
运行结果如下:

原文地址: https://www.cveoy.top/t/topic/bxu9 著作权归作者所有。请勿转载和采集!