Ao ler um artigo para minha tese, encontrei este gráfico (b) :
Tentei recriar o segundo gráfico que é o que gostaria de usar para meus resultados:
import numpy as np
import matplotlib.pyplot as plt
from matplotlib.gridspec import GridSpec
years = np.linspace(1300, 2000, 700)
np.random.seed(42)
delta_13C = np.cumsum(np.random.normal(0, 0.1, 700))
delta_13C = delta_13C - np.mean(delta_13C)
delta_18O = np.cumsum(np.random.normal(0, 0.08, 700))
delta_18O = delta_18O - np.mean(delta_18O)
temp_anomaly = np.cumsum(np.random.normal(0, 0.03, 700))
temp_anomaly = temp_anomaly - np.mean(temp_anomaly)
temp_anomaly[-100:] += np.linspace(0, 1.5, 100)
plt.style.use('default')
plt.rcParams['font.size'] = 12
plt.rcParams['axes.linewidth'] = 1.5
plt.rcParams['axes.labelsize'] = 14
fig = plt.figure(figsize=(10, 8))
gs = GridSpec(3, 1, height_ratios=[1, 1, 1], hspace=0.2)
ax1 = fig.add_subplot(gs[0])
ax1.plot(years, delta_13C, color='green', linewidth=1.0)
ax1.set_ylabel('First', color='green', labelpad=10)
ax1.tick_params(axis='y', colors='green')
ax1.set_xlim(1300, 2000)
ax1.set_ylim(-4, 4)
ax1.xaxis.set_visible(False)
ax1.spines['top'].set_visible(False)
ax1.spines['bottom'].set_visible(False)
ax1.spines['right'].set_visible(False)
ax1.spines['left'].set_color('green')
ax2 = fig.add_subplot(gs[1])
ax2.plot(years, delta_18O, color='blue', linewidth=1.0)
ax2.yaxis.tick_right()
ax2.yaxis.set_label_position("right")
ax2.set_ylabel('Second', color='blue', labelpad=10)
ax2.tick_params(axis='y', colors='blue')
ax2.set_xlim(1300, 2000)
ax2.set_ylim(-3, 3)
ax2.xaxis.set_visible(False)
ax2.spines['top'].set_visible(False)
ax2.spines['bottom'].set_visible(False)
ax2.spines['left'].set_visible(False)
ax2.spines['right'].set_color('blue')
ax3 = fig.add_subplot(gs[2])
ax3.plot(years, temp_anomaly, color='gray', linewidth=1.0)
ax3.set_ylabel('Third', color='black', labelpad=10)
ax3.set_xlim(1300, 2000)
ax3.set_ylim(-1.0, 1.5)
ax3.set_xlabel('Year (CE)')
ax3.spines['top'].set_visible(False)
ax3.spines['right'].set_visible(False)
plt.show()
Mas o resultado é um pouco diferente:
Como posso aproximar os subplots sem bloquear um ao outro? Como você pode ver no gráfico no artigo de referência, as linhas dos subplots quase se tocam.