kennlinie_diode.py 758 B

12345678910111213141516171819202122232425262728293031323334
  1. import matplotlib.pyplot as plt
  2. import numpy as np
  3. import csv
  4. datei = "diode.csv"
  5. U = []
  6. I = []
  7. with open(datei, 'r', newline='') as csvfile:
  8. reader = csv.reader(csvfile, delimiter=',')
  9. # Header überspringen
  10. next(reader)
  11. for row in reader:
  12. U.append(float(row[0]))
  13. I.append(float(row[1]))
  14. U = np.array(U)
  15. I = np.array(I)
  16. # Erstelle das Plot
  17. plt.plot(U, I, label='Kennline Si-Diode')
  18. plt.scatter(U, I, color='blue', s=50, marker='o', label='Messpunkte')
  19. plt.title("U-I Kennlinie")
  20. plt.xlabel("U in V")
  21. plt.ylabel("I in mA")
  22. plt.axhline(0, color='black',linewidth=1) # x-Achse
  23. plt.axvline(0, color='black',linewidth=1) # y-Achse
  24. plt.grid(True)
  25. plt.legend()
  26. # Zeige das Plot
  27. plt.show()