#!/usr/bin/env python
import numpy as np
import matplotlib.pyplot as plt
from matplotlib.patches import Polygon, Circle
from matplotlib.collections import PatchCollection
import json
result = open("Walls.json","r",encoding="utf-8")
print(type(result))
data = json.load(result)
outlines = data['outlines']
print(len(outlines))
patches = []
for lines in outlines:
poly = []
for key, value in lines.items():
point = []
for k, v in value.items():
if k != "z":
point.append(float(v)/100.0)
poly.append(point)
polygon = Polygon(poly, True)
patches.append(polygon)
result = open("Pillars.json","r",encoding="utf-8")
print(type(result))
data = json.load(result)
outlines = data['outlines']
print(len(outlines))
for lines in outlines:
poly = []
for key, value in lines.items():
point = []
for k, v in value.items():
if k != "z":
point.append(float(v)/100.0)
poly.append(point)
polygon = Polygon(poly, True)
patches.append(polygon)
fig, ax = plt.subplots()
ax.axis([-65,65,-100,30])
colors = 100*np.random.rand(len(patches))
p = PatchCollection(patches, alpha=0.4)
p.set_array(np.array(colors))
ax.add_collection(p)
fig.colorbar(p, ax=ax)
plt.show()
matplotlib画polygon, circle
最新推荐文章于 2024-05-16 05:22:43 发布