SpaceQuester

Untitled

Nov 10th, 2025
108
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.75 KB | None | 0 0
  1. import os
  2. import numpy as np
  3. import matplotlib.pyplot as plt
  4.  
  5. # --- Настройки ---
  6. FontSize = 10
  7.  
  8. # Ищем файлы в текущей рабочей директории
  9. # (это самый надежный способ, если вы загрузили файлы в среду выполнения)
  10. current_dir = os.getcwd()
  11.  
  12. # --- Загрузка данных ---
  13. filename1 = 'results.txt'
  14. if not os.path.exists(filename1):
  15.     raise FileNotFoundError(f"Файл '{filename1}' не найден в директории: {current_dir}")
  16.  
  17. Data = np.loadtxt(filename1)
  18. time = Data[:, 0]
  19. Ca   = Data[:, 1]
  20. V    = Data[:, 4]
  21. print("Data: time, Ca, V have been loaded")
  22.  
  23. # --- Построение графиков ---
  24. fig, axs = plt.subplots(2, 1, figsize=(12, 8))
  25.  
  26. # Subplot 1: Ca(t)
  27. axs[0].plot(time, Ca, 'r', linewidth=1)
  28. axs[0].grid(True)
  29. axs[0].set_ylim([0, 0.7])
  30. axs[0].set_yticks([0, 0.1, 0.2, 0.3, 0.4, 0.5, 0.6, 0.7])
  31. axs[0].set_xlim([0, 30])
  32. axs[0].set_xticks(range(0, 31, 5))
  33. axs[0].tick_params(axis='both', labelsize=FontSize)
  34. axs[0].set_title(r'$Ca^{2+}(t)$', fontsize=FontSize)
  35. axs[0].set_xlabel('Time, s', fontsize=FontSize)
  36. axs[0].set_ylabel(r'$[Ca^{2+}], \mu M$', fontsize=FontSize)
  37.  
  38. # Subplot 2: V(t) — раскомментируйте, если нужно
  39. axs[1].plot(time, V, 'b', linewidth=1)
  40. axs[1].grid(True)
  41. axs[1].set_ylim([-80, 20])
  42. axs[1].set_xlim([0, 10])
  43. axs[1].set_xticks(range(0, 11, 1))
  44. axs[1].tick_params(axis='both', labelsize=FontSize)
  45. axs[1].set_title('V(t)', fontsize=FontSize)
  46. axs[1].set_xlabel('Time, s', fontsize=FontSize)
  47. axs[1].set_ylabel('V, mV', fontsize=FontSize)
  48.  
  49. plt.tight_layout()
  50. fig.savefig('fig_Ca_V.png', dpi=300, bbox_inches='tight')
  51. print("Plot fig_Ca_V has been saved")
Advertisement
Add Comment
Please, Sign In to add comment