当前位置:网站首页>matplotlib画polygon, circle
matplotlib画polygon, circle
2022-08-03 19:30:00 【whuzhang16】
#!/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()
边栏推荐
猜你喜欢
随机推荐
【C语言学习笔记(五)】while循环与for循环
基于DMS的数仓智能运维服务,知多少?
Postgresql源码(65)新快照体系Globalvis工作原理分析
ECCV2022 | 用于视频问题回答的视频图Transformer
Brush the topic of mobile zero power button
微信小程序分享功能
if/else或switch替换为Enum
力扣解法汇总899-有序队列
2022 CCF中国开源大会会议通知(第三轮)
MySQL基础
友宏医疗与Actxa签署Pre-M Diabetes TM 战略合作协议
高效目标检测:动态候选较大程度提升检测精度(附论文下载)
盲僧发现了华点——教你如何使用API接口获取数据
Calculation of the array serial number of Likou brush questions (one question per day 7/28)
Don't look down upon the WebSocket!Long connection, stateful, two-way, full-duplex king is Fried
Handler 源码解析
Shell programming loop statement
epoll + 线程池 + 前后置服务器分离
FreeRTOS Intermediate
LeetCode 622. 设计循环队列