【发布时间】:2020-03-21 08:28:37
【问题描述】:
这是我的代码:
import matplotlib.pyplot as plt
from matplotlib.patches import RegularPolygon
import numpy as np
offCoord = [[-2,-2],[-1,-2],[0,-2],[1,-2],[2,-2]]
fig, ax = plt.subplots(1)
ax.set_aspect('equal')
for c in offCoord:
hex = RegularPolygon((c[0], c[1]), numVertices=6, radius=2./3., alpha=0.2, edgecolor='k')
ax.add_patch(hex)
plt.autoscale(enable = True)
plt.show()
附图中的预期结果与实际结果
请告诉我为什么我的六边形不是边接边排列而是相互重叠的? 我做错了什么?
【问题讨论】:
-
radius太大。看起来RegularPolygon将“半径”定义为中心和每个顶点之间的距离。因此,您需要使用一些几何图形来确定该值应该是多少,以便从中心到边缘的距离为 1。
标签: python matplotlib coordinate-systems hexagonal-tiles