我在python中使用matplotlib制作了下图,并附加了我用来制作此代码的代码。
竞技场代码
import matplotlib.pyplot as plt
import matplotlib.patches as patches
obs_boundary = [
[0, 0, 10, 600],
[0, 600, 900, 10],
[10, 0, 900, 10],
[900, 10, 10, 600]
]
obs_cir_own = [
[50,500,10],
[100,300,10],
[240,240,10],
[300,400,10],
[190,50,10]
]
obs_cir_opp = [
[700, 420, 10],
[460, 200, 10],
[550, 500, 10],
[670, 70, 10],
[800, 230, 10],
[600,300,10]
]
fig, ax = plt.subplots()
for (ox, oy, w, h) in obs_boundary:
print(ox, oy, w, h)
ax.add_patch(
patches.Rectangle(
(ox, oy), w, h,
edgecolor='black',
facecolor='black',
fill=True
)
)
for (ox, oy,r) in obs_cir_own:
ax.add_patch(
patches.Circle(
(ox, oy), r,
edgecolor='black',
facecolor='green',
fill=True
)
)
for (ox, oy, r) in obs_cir_opp:
ax.add_patch(
patches.Circle(
(ox, oy), r,
edgecolor='black',
facecolor='red',
fill=True
)
)
plt.plot(50,50, "bs", linewidth=30)
plt.plot(870, 550, "ys", linewidth=30)
name='arena'
plt.title(name)
plt.axis("equal")
因此,我想使用C ++实现类似的竞技场,但我不知道该怎么做?我研究过,我再次对qtplot有所了解,对qt不太了解。因此,qtplot是唯一的方法还是有一些更简单的方法。请告诉我如何在C ++中实现此功能。
您可以尝试https://github.com/lava/matplotlib-cpp,无论如何它看起来都只是matplotlib的包装,因此最终您仍然会调用/使用Python和matplotlib。这样,您可能可以将您的代码几乎逐字复制到“ C ++”。
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句