-
Notifications
You must be signed in to change notification settings - Fork 0
/
graph.py
100 lines (73 loc) · 1.98 KB
/
graph.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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
import pandas as pd
import csv
import sys
import matplotlib.pyplot as plt
# Read the CSV file into a pandas DataFrame
data = pd.read_csv(sys.argv[1], header=None)
# Extract the x and y values from the DataFrame
x = data.iloc[:, 0]
y = data.iloc[:, 1]
colors = []
for i in range(len(x)):
colors.append('red')
# Create a scatter plot
fig, ax = plt.subplots()
scatter = ax.scatter(x, y, c=colors)
# Add text on hover using matplotlib's annotate function
tooltip = plt.gca().annotate('', xy=(0, 0), xytext=(20, 20), textcoords='offset points', bbox=dict(boxstyle='round,pad=0.5', fc='yellow', alpha=0.5))
lines = ax.plot(x, y, '-')
csv_file = "middle.csv"
# Lists to store the x and y coordinates
x_values = []
y_values = []
xv2 = []
yv2 = []
idx = 0
# Read data from the CSV file
with open(csv_file, "r") as file:
reader = csv.reader(file)
for row in reader:
idx += 1
x_values.append(float(row[0]))
y_values.append(float(row[1]))
# Plot the graph
plt.plot(x_values, y_values, marker='.', color='g')
plt.plot(xv2, yv2, marker='x')
csv_file = "edges.csv"
# Lists to store the x and y coordinates
x_values = []
y_values = []
xv2 = []
yv2 = []
idx = 0
# Read data from the CSV file
with open(csv_file, "r") as file:
reader = csv.reader(file)
for row in reader:
idx += 1
if idx % 2 == 0:
x_values.append(float(row[0]))
y_values.append(float(row[1]))
# Plot the graph
plt.plot(x_values, y_values, marker='.', color='khaki')
x_values = []
y_values = []
xv2 = []
yv2 = []
idx = 0
# Read data from the CSV file
with open(csv_file, "r") as file:
reader = csv.reader(file)
for row in reader:
idx += 1
if idx % 2 == 1:
x_values.append(float(row[0]))
y_values.append(float(row[1]))
# Plot the graph
plt.plot(x_values, y_values, marker='.', color='khaki')
plt.xlabel('X-axis')
plt.ylabel('Y-axis')
plt.title('Graph from CSV Data')
plt.grid(True)
# Show the scatter plot
plt.show()