28 lines
987 B
Python
28 lines
987 B
Python
import matplotlib.pyplot as plt
|
|
import numpy as np
|
|
from scipy.interpolate import make_interp_spline
|
|
|
|
abstand = np.array([1, 2, 3, 4, 5, 6, 7, 8, 9, 10])
|
|
messwerte = np.array([65.01, 40.41, 26.67, 19.65, 15.61, 13.13, 11.11, 10.08, 8.85, 7.93])
|
|
|
|
konstante = messwerte[0] * abstand[0]
|
|
idealwerte = konstante / abstand
|
|
|
|
plt.figure(figsize=(10, 6))
|
|
|
|
# Spline-Interpolation für Idealwerte
|
|
xnew = np.linspace(abstand.min(), abstand.max(), 300)
|
|
spl_ideal = make_interp_spline(abstand, idealwerte, k=3)
|
|
idealwerte_smooth = spl_ideal(xnew)
|
|
|
|
# Darstellung der Messwerte und Idealwerte
|
|
plt.plot(abstand, messwerte, marker='o', linestyle='-', label='Messwerte', color='blue') # Keine Verbindungslinien für Messwerte
|
|
plt.plot(xnew, idealwerte_smooth, label='Idealwerte', marker='x', linestyle='--', color='green')
|
|
|
|
plt.xlabel('Abstand l [mm]')
|
|
plt.ylabel('Kapazität C [pF]')
|
|
plt.grid(True)
|
|
plt.legend()
|
|
plt.xticks(abstand)
|
|
plt.yticks(np.arange(min(messwerte), max(messwerte) + 5, 5.0))
|
|
plt.show() |