Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import os
- import numpy as np
- import matplotlib.pyplot as plt
- # --- Настройки ---
- FontSize = 10
- # Ищем файлы в текущей рабочей директории
- # (это самый надежный способ, если вы загрузили файлы в среду выполнения)
- current_dir = os.getcwd()
- # --- Загрузка данных ---
- filename1 = 'results_Ca_IP3_z.txt'
- if not os.path.exists(filename1):
- raise FileNotFoundError(f"Файл '{filename1}' не найден в директории: {current_dir}")
- Data = np.loadtxt(filename1)
- time = Data[:, 0]
- Ca = Data[:, 1]
- IP3 = Data[:, 2]
- z = Data[:, 3]
- print("Data: time, Ca, IP3, z have been loaded")
- filename2 = 'v_4.txt'
- # Замечание: в оригинальном коде v_4 загружается, но нигде не используется.
- # Поэтому мы проверим его наличие, но не будем рисовать, если это не нужно.
- if os.path.exists(filename2):
- v_4 = np.loadtxt(filename2)
- print("Data: v_4 has been loaded")
- else:
- print(f"Предупреждение: файл '{filename2}' не найден. Переменная v_4 не будет использована.")
- # --- Построение графиков ---
- fig, axs = plt.subplots(2, 2, figsize=(12, 8))
- # Subplot 1: Ca(t)
- axs[0, 0].plot(time, Ca, 'r', linewidth=1)
- axs[0, 0].grid(True)
- axs[0, 0].set_ylim([0, 0.7])
- axs[0, 0].set_yticks([0, 0.1, 0.2, 0.3, 0.4, 0.5, 0.6, 0.7])
- axs[0, 0].set_xlim([0, 180])
- axs[0, 0].set_xticks(range(0, 181, 20))
- axs[0, 0].tick_params(axis='both', labelsize=FontSize)
- axs[0, 0].set_title(r'$Ca^{2+}(t)$', fontsize=FontSize)
- axs[0, 0].set_xlabel('Time, s', fontsize=FontSize)
- axs[0, 0].set_ylabel(r'$[Ca^{2+}], \mu M$', fontsize=FontSize)
- # Subplot 2: IP3(t)
- axs[0, 1].plot(time, IP3, 'b', linewidth=1)
- axs[0, 1].grid(True)
- axs[0, 1].set_xlim([0, 180])
- axs[0, 1].set_xticks(range(0, 181, 20))
- axs[0, 1].tick_params(axis='both', labelsize=FontSize)
- axs[0, 1].set_title(r'$IP_3(t)$', fontsize=FontSize)
- axs[0, 1].set_xlabel('Time, s', fontsize=FontSize)
- axs[0, 1].set_ylabel(r'$[IP_3], \mu M$', fontsize=FontSize)
- # Subplot 3: z(t)
- axs[1, 0].plot(time, z, 'b', linewidth=1)
- axs[1, 0].grid(True)
- axs[1, 0].set_ylim([0, 1])
- axs[1, 0].set_xlim([0, 180])
- axs[1, 0].set_xticks(range(0, 181, 20))
- axs[1, 0].tick_params(axis='both', labelsize=FontSize)
- axs[1, 0].set_title('z(t)', fontsize=FontSize)
- axs[1, 0].set_xlabel('Time, s', fontsize=FontSize)
- axs[1, 0].set_ylabel('z', fontsize=FontSize)
- # Subplot 4: Phase portrait Ca(z)
- axs[1, 1].plot(z, Ca, 'b', linewidth=1)
- axs[1, 1].grid(True)
- axs[1, 1].set_ylim([0, 0.7])
- axs[1, 1].set_yticks([0, 0.1, 0.2, 0.3, 0.4, 0.5, 0.6, 0.7])
- axs[1, 1].set_xlim([0, 1])
- axs[1, 1].set_xticks([0, 0.1, 0.2, 0.3, 0.4, 0.5, 0.6, 0.7, 0.8, 0.9, 1.0])
- axs[1, 1].tick_params(axis='both', labelsize=FontSize)
- axs[1, 1].set_title('Phase portrait: Ca(z)', fontsize=FontSize)
- axs[1, 1].set_xlabel('z', fontsize=FontSize)
- axs[1, 1].set_ylabel(r'$Ca^{2+}, \mu M$', fontsize=FontSize)
- plt.tight_layout()
- fig.savefig('fig_Ca_IP3_z.png', dpi=300, bbox_inches='tight')
- print("Plot fig_Ca_IP3_z has been saved")
Advertisement
Add Comment
Please, Sign In to add comment