From 1354f0ec2f21eed90d67a37e448c4fca77b4bfe4 Mon Sep 17 00:00:00 2001 From: Suwako Moriya Date: Sun, 11 Nov 2018 17:31:27 +0100 Subject: [PATCH] [plotgen] added circle support --- plotgen.py | 33 ++++++++++++++++++--------------- 1 file changed, 18 insertions(+), 15 deletions(-) diff --git a/plotgen.py b/plotgen.py index 9d80c66..16cc664 100755 --- a/plotgen.py +++ b/plotgen.py @@ -3,17 +3,26 @@ import matplotlib.pyplot as plt import mplleaflet import fetch - - +from tqdm import tqdm +import time +import math +def circlepolygon(radius, center, resolution=20): + points=[[center[0] + math.cos(((2*math.pi)/resolution)*i)*radius*1.15, center[1] + math.sin(((2*math.pi)/resolution)*i)*radius] for i in range(resolution)] + return points def genplot(diclist): - for index, area in enumerate(diclist): - if index in [210,223]: - continue + for area in tqdm(diclist, ncols=50): for figure in area['zone']: if figure[0] == 'cercle' : - print("cercle") + xcoords,ycoords=[],[] + for xaxis,yaxis in circlepolygon(figure[1]/100000, figure[2::], resolution=100): + xcoords.append(xaxis) + ycoords.append(yaxis) + xcoords.append(xcoords[0]) + ycoords.append(ycoords[0]) + plt.plot(xcoords,ycoords,'b') + plt.plot(figure[2],figure[3],'rs') + plt.fill(xcoords,ycoords,'g') else: - print("polygone") xcoords,ycoords=[],[] for xaxis,yaxis in figure: xcoords.append(xaxis) @@ -24,14 +33,8 @@ def genplot(diclist): plt.plot(xcoords,ycoords,'rs') plt.fill(xcoords,ycoords,'g') return plt - - -#plt.plot([15,16,17,15],[6,7,18,6],'b') -#plt.plot(17,6,'b') -#plt.plot(16,7,'rs') -#plt.fill([15,16,17,15],[6,7,18,6]) -#mplleaflet.show() + if __name__ == '__main__': - plt=genplot(fetch.fetch()) + genplot(fetch.fetch()) mplleaflet.show() \ No newline at end of file