If I were to have a data for a one-dimensional system evolving in time, essentially a two-dimensional array, and the array at each point in time is of the same size, how would I produce something like this:
(Taken from Turing’s model for biological pattern formation and the robustness problem by Maini et al., 2012)
I have tried to replicate this with matplotlib by resizing (or rather synthesising) each instance in time to an array of specific length, according to the growth of the domain, and filling the rest of the array with NaNs.
import numpy as np
import matplotlib.pyplot as plt
N = 750
x = []
t = np.linspace(0, N, N)
def asize(i, N): # Computes the necessary size of the array
return int(N*np.exp(2*(i-N)/N))
for i in range(N): # Concatenating data with whitespace
x.append(np.concatenate((np.sin(np.linspace(0,3*np.pi,asize(i,N)))**2,
np.NaN*np.zeros(N-asize(i,N)))))
x = np.transpose(np.array(x))
plt.imshow(x, cmap = 'Spectral_r', origin = 'lower')
plt.plot(t, N*np.exp(2*(t-N)/N), c='white', lw = 2) # Making the boundary smoother
plt.axis([0,N,0,N])
plt.xlabel('$t$')
plt.ylabel('$x$')
plt.xticks([0,250,500,750])
plt.yticks([0,250,500,750])
plt.show()
Naturally, with actual data this method would be even more tedious, requiring to somehow squish the arrays. Is there a more reasonable way of doing this with matplotlib, Mathematica or any other tool?