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.txt'
- if not os.path.exists(filename1):
- raise FileNotFoundError(f"Файл '{filename1}' не найден в директории: {current_dir}")
- Data = np.loadtxt(filename1)
- time = Data[:, 0]
- Ca = Data[:, 1]
- V = Data[:, 4]
- print("Data: time, Ca, V have been loaded")
- # --- Построение графиков ---
- fig, axs = plt.subplots(2, 1, figsize=(12, 8))
- # Subplot 1: Ca(t)
- axs[0].plot(time, Ca, 'r', linewidth=1)
- axs[0].grid(True)
- axs[0].set_ylim([0, 0.7])
- axs[0].set_yticks([0, 0.1, 0.2, 0.3, 0.4, 0.5, 0.6, 0.7])
- axs[0].set_xlim([0, 30])
- axs[0].set_xticks(range(0, 31, 5))
- axs[0].tick_params(axis='both', labelsize=FontSize)
- axs[0].set_title(r'$Ca^{2+}(t)$', fontsize=FontSize)
- axs[0].set_xlabel('Time, s', fontsize=FontSize)
- axs[0].set_ylabel(r'$[Ca^{2+}], \mu M$', fontsize=FontSize)
- # Subplot 2: V(t) — раскомментируйте, если нужно
- axs[1].plot(time, V, 'b', linewidth=1)
- axs[1].grid(True)
- axs[1].set_ylim([-80, 20])
- axs[1].set_xlim([0, 10])
- axs[1].set_xticks(range(0, 11, 1))
- axs[1].tick_params(axis='both', labelsize=FontSize)
- axs[1].set_title('V(t)', fontsize=FontSize)
- axs[1].set_xlabel('Time, s', fontsize=FontSize)
- axs[1].set_ylabel('V, mV', fontsize=FontSize)
- plt.tight_layout()
- fig.savefig('fig_Ca_V.png', dpi=300, bbox_inches='tight')
- print("Plot fig_Ca_V has been saved")
Advertisement
Add Comment
Please, Sign In to add comment