Python-визуализация сетки
This commit is contained in:
26
visual_mesh.py
Normal file
26
visual_mesh.py
Normal file
@@ -0,0 +1,26 @@
|
||||
import matplotlib.pyplot as plt
|
||||
|
||||
x_coords = []
|
||||
y_coords = []
|
||||
|
||||
try:
|
||||
filename = input("Input name: ")
|
||||
with open(f'{filename}', 'r') as file:
|
||||
lines = file.readlines()
|
||||
|
||||
for line in lines[2:]:
|
||||
if line.strip():
|
||||
x, y = map(float, line.strip().split())
|
||||
x_coords.append(x)
|
||||
y_coords.append(y)
|
||||
|
||||
plt.figure(figsize=(10, 6))
|
||||
plt.scatter(x_coords, y_coords, s=10, c='blue', alpha=0.5)
|
||||
plt.xlabel('X')
|
||||
plt.ylabel('Y')
|
||||
plt.grid(True)
|
||||
plt.axis('equal')
|
||||
plt.savefig(f"{filename[:-4]}.png")
|
||||
plt.show()
|
||||
except FileNotFoundError:
|
||||
print(f"{filename} not found. ABORT!")
|
||||
Reference in New Issue
Block a user