tocarina/anosem/clock/main.py

137 lines
3.5 KiB
Python
Raw Normal View History

2022-02-24 11:53:43 +01:00
from __future__ import division
#import matplotlib.pyplot as plt
from plt import *
import numpy as np
from numpy import pi
def gen(hour=None):
staticmode=False
mult=1.0
my_dpi=96*mult
siz=768
fig=plt.figure(figsize=(siz/my_dpi,siz/my_dpi),dpi=my_dpi)
fig.patch.set_facecolor("white")
angles = 2*pi*np.random.randint(0,864000,100)/86400
ax = plt.subplot(111, polar=True)
#ax.set_facecolor("white")
#ax.figure(figsize=(10,10))
#plt.polar()
#ax.scatter(angles, np.ones(100)*1)
#ax.bar(angles, np.full(100, 0.9), width=0.1, bottom=0.0, color='r', linewidth=0)
#ax.bar(angles, np.full(100, 0.9), width=0.05, bottom=0.89, color='r', linewidth=0)
ax.grid(b=False)
alpha=pi/6
def ophase(x,y,c):ax.plot([x*alpha,y*alpha],[8,8],color=c)
ophase(0,3,"red")
ophase(3,8.5,"blue")
ophase(8.5,10.5,"yellow")
ophase(10.5,12,"green")
ax.text(2.8*alpha,0.4,"Datasets",{"size":18,"color":"red"},rotation=0)
ax.text(6.5*alpha,0.5,"Algorithms",{"size":18,"color":"blue"},rotation=8)
ax.text(8.6*alpha,0.8,"Analysis",{"size":18,"color":"yellow"},rotation=15)
ax.text(10.7*alpha,0.8,"Application",{"size":18,"color":"green"},rotation=20)
labels=["Video Data","Text Data","Graph Data","High dim Data","Density OD","Subspace preprocessing","Transformations","Ensembles","Active AD","Explainability","Interpretation","Device Failure"]
# suppress the radial labels
plt.setp(ax.get_yticklabels(), visible=False)
# set the circumference labels
if staticmode:
ax.set_xticks(np.linspace(0, 2*pi, 12, endpoint=False))
ax.set_xticklabels([12,1,2,3,4,5,6,7,8,9,10,11])
ax.set_xticklabels(labels)
else:
ax.set_xticks([])
data=[
[1.04,0.16],
[0.91,0.08],
[0.88,-0.05],
[1.03,-0.17],
[1.05,-0.20],
[1.11,-0.30],
[1.10,-0.20],
[1.20,-0.10],
[1.20,0.05],
[1.10,0.14],
[1.10,0.19],
[1.07,0.22],
]
radii=[d[0] for d in data]
deltap=[d[1] for d in data]
for i,(lab,rad,dp) in enumerate(zip(labels,radii,deltap)):
theta=alpha*i
theta90=theta*180/pi
ax.text(theta-dp,rad,lab,{"size":13,"color":"black"},rotation=-theta90)
def line(hour):
plt.plot([hour*alpha,hour*alpha],[0.0,1.0],color="black")
def sline(hour):
plt.plot([hour*alpha,hour*alpha],[1.00,1.0],color="black")
if not hour is None:
line(hour)
for i in range(12):
sline(i)
try:
mplcyberpunk.add_underglow()
mplcyberpunk.add_glow_effects()
except:pass
plt.plot([7*alpha,8*alpha],[1.0,1.0],color="blue")
# make the labels go clockwise
ax.set_theta_direction(-1)
# place 0 at the top
ax.set_theta_offset(pi/2.0)
# plt.grid('off')
# put the points on the circumference
plt.ylim(0,1)
#plt.show()
if hour is None:
plt.savefig(f"output.png",facecolor="white",format="png")
plt.savefig(f"output.pdf",facecolor="white",format="pdf")
else:
plt.savefig(f"output{hour}.png",facecolor="white",format="png")
plt.savefig(f"output{hour}.pdf",facecolor="white",format="pdf")
try:
plt.how()
except:
plt.show()
gen()
for i in range(1,13):
gen(i)