python2.7绘制没有自相交的简单多边形

时间:2018-05-24 17:26:43

标签: python matplotlib plot polygon shapely

我想绘制简单的多边形,这意味着使用x&和多边形在多边形中没有自相交。 y位置。但我得到的结果是多边形的蝴蝶形状。

我知道如果我将li_feasible_points更改为[[0,2],[2,2],[4,0],[2,0]]以便在此时间内绘制简单的多边形。

但我想要的是绘制简单的多边形,而不是通过任何角点位置列表进行自相交。有没有办法解决这个问题?

以下是我的代码和我的结果。

from matplotlib import pyplot as plt
fig, ax = plt.subplots(figsize=(6, 6))

x_lim = 5
y_lim = 10
x = np.linspace(0, x_lim)
y = np.linspace(0, y_lim)

li_feasible_points = [[0.0, 2.0], [4.0, 0.0], [2.0, 0.0], [2.0, 2.0]]
line = plt.Polygon(li_feasible_points, closed=False, color='r', fill=True, edgecolor='r')
plt.gca().add_line(line)

plt.xlabel(li_var_names[0])
plt.ylabel(li_var_names[1])
plt.xlim(0, x_lim)
plt.ylim(0, y_lim)
plt.show()

enter image description here

我期待着你的帮助。谢谢。

0 个答案:

没有答案
相关问题