简体   繁体   English

在python中的点之间绘制网格线

[英]drawing grid lines beween points in python

I have 6 points in the (x,y) plane: x=[x1,x2,x3,x4,x5,x6] and y=[y1,y2,y3,y4,y5,y6] 我在(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()

I want to between the points, draw entirely parallel lines on each axis x,y (like photo ). 我想在两点之间,在每个轴x,y上绘制完全平行的线(如photo )。 and how to hide x and y axis on diagram. 以及如何在图表上隐藏x和y轴。 I want to draw a 2D view of the beams and columns of 3 story building; 我想绘制3层建筑的梁和柱的2D视图; does matplotlib bring me to my goal or should I go to other libraries? matplotlib带我实现我的目标还是应该去其他图书馆?

Absolutely matplotlib can do this. 绝对matplotlib可以做到这一点。 Take a look at their Rectangle Patch : 看看他们的矩形补丁

Example usage (you'll have to modify this to your needs): 用法示例(您必须根据需要对其进行修改):

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()

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM