-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.py
42 lines (29 loc) · 1 KB
/
main.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
import pandas as pd
import matplotlib.pyplot as plt
import colorsys
import subprocess
def run_chagapy():
subprocess.run(["chagapy", "-g", "NoNeighbor", "-v", "5"])
def set_coloring(dataset):
num_vertices = dataset["ref"].max() + 1
delta = 1 / (num_vertices)
dataset["color"] = ""
dataset["dist"] = dataset["dist"] / dataset["dist"].max()
for index, data in dataset.iterrows():
hsv_color = (0.0 + data["ref"] * delta, -data["dist"] + 1, 1.0)
dataset.at[index, "color"] = colorsys.hsv_to_rgb(*hsv_color)
return dataset
def plot_data(dataset):
fig, ax = plt.subplots(1, 1, figsize=(10, 10))
fig.patch.set_facecolor((0.0, 0.0, 0.0))
ax.set_facecolor((0.0, 0.0, 0.0))
plt.axis("off")
dataset.plot.scatter(x="x", y="y", ax=ax, s=0.1, c=dataset["color"])
plt.show()
def main():
run_chagapy()
dataset = pd.read_csv("test.csv", names=["x", "y", "ref", "dist"])
set_coloring(dataset)
plot_data(dataset)
if __name__ == "__main__":
main()