-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathparser2d-xyplot.py
More file actions
31 lines (26 loc) · 883 Bytes
/
parser2d-xyplot.py
File metadata and controls
31 lines (26 loc) · 883 Bytes
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
import numpy as np
import matplotlib.pyplot as plt
import pandas as pd
from scipy.interpolate import griddata
# Read the data from the CSV file
# Assuming the CSV file has columns 'x', 'y', and 'voltage'
data = pd.read_csv('square.csv')
# Extract x, y, and voltage values from the DataFrame
x = data['x'].values
y = data['y'].values
voltage = data['voltage'].values
# Create a grid for interpolation
xi = np.linspace(min(x), max(x), 100)
yi = np.linspace(min(y), max(y), 100)
X, Y = np.meshgrid(xi, yi)
# Perform cubic interpolation
Z = griddata((x, y), voltage, (X, Y), method='cubic')
# Create the contour plot
plt.figure(figsize=(8, 6))
contour = plt.contourf(X, Y, Z, levels=20, cmap='viridis')
plt.colorbar(contour, label="Voltage")
plt.title("Voltage Contour Plot")
plt.xlabel("X Coordinate")
plt.ylabel("Y Coordinate")
plt.grid(True, linestyle='--', alpha=0.7)
plt.show()