Matlab的代码怎么改写成python呢?

`` 
Matlab的这四行代码怎么改写成python呢?
tt = 0:N-1;  
ff = (0:N/2-1)/N; 
tfr = tfr/max(max(abs(tfr))); 
imagesc(tt*dt,ff*fs/2,abs(tfr(1:N/2,:)));

```


import numpy as np
import matplotlib.pyplot as plt

tt = np.arange(N)
ff = np.arange(N/2)/N*fs/2
tfr = tfr/np.max(np.abs(tfr))
plt.imshow(abs(tfr[:int(N/2),:]), extent=[tt[0]*dt,tt[-1]*dt,ff[0],ff[-1]])
plt.xlabel('Time (s)')
plt.ylabel('Frequency (Hz)')
plt.show()