在 Python 中绘制网格线



我在(x,y)平面上有 6 个点:x=[x1,x2,x3,x4,x5,x6]y=[y1,y2,y3,y4,y5,y6]

import matplotlib.pyplot as plt    
x = [0, 2, 4, 0, 2, 4, 0, 2, 4]
y = [0, 0, 0, 3, 3, 3, 7, 7, 7]
plt.scatter(x, y)
plt.show()

我想在点之间,在每个轴上绘制完全平行的线x,y(如照片)。 以及如何在图表上隐藏 X 轴和 y 轴。我想绘制 3 层建筑的梁柱的 2D 视图;matplotlib是让我达到我的目标还是应该去其他图书馆?

绝对matplotlib可以做到这一点。看看他们的矩形补丁:

示例用法(您必须根据需要修改它):

import matplotlib.pyplot as plt
import matplotlib.patches as patches
fig = plt.figure()
ax = fig.add_subplot()
rect = patches.Rectangle(
    (0.1, 0.1),
    0.5,
    0.5,
    fill=False
)
ax.add_patch(rect)
fig.show()

最新更新