我試圖從“Thomas H. Cormen、Charles E. Leiserson、Ronald L. Rivest 和 Clifford Stein.Introduction to Algorithms, 3rd Edition. The MIT Press, 2009”的第 405 頁復制該圖

這是代碼
plt.plot(0,6,'o',c='k')
plt.plot(1,0,'o',c='k')
plt.plot((0,1),(6,0))
plt.xlim([0, 9])
plt.ylim([0, 7])
plt.grid()
這使點不完整

相反,以下代碼完全渲染了點,x=1、3 處的網格線消失了

如何在保留所有網格線的同時完全渲染點?
uj5u.com熱心網友回復:
使用
整個圖:
fig, ax = plt.subplots()
x = [0, 1, 6, 8, 7, 5, 2]
y = [6, 0, 1, 2, 5, 4, 3]
ax.fill(x, y, fill=False)
ax.scatter(x, y, c='k')
ax.set_xlim([-1, 9])
ax.set_ylim([-1, 7])
ax.yaxis.set_major_locator(MultipleLocator(1))
ax.xaxis.set_major_locator(MultipleLocator(1))
ax.grid()
ax.set_axisbelow(True)

編輯:根據您的(已洗掉)
轉載請註明出處,本文鏈接:https://www.uj5u.com/qukuanlian/512068.html
