title: Adding timestamp on the top of the plot using Matplotlib
body: <p>Is there a way to add timestamp <code>t=0</code> on the top of the plot at the specific location as shown in the expected output? In general, does Python have a time counter which appears on every frame and is split according to the number of frames? I present the current and expected outputs.</p>
  <pre><code>import matplotlib as mpl
  import matplotlib.pyplot as plt
  from matplotlib.patches import Rectangle
  import numpy as np
  from matplotlib.colors import Normalize
  from matplotlib import cm
  import math
  from  numpy import nan
  
  fig,aPe = plt.subplots(1)
  n=3
  arMax=[]
  arMin=[]
  
  N=2*n*(n-1)
  
  J = np.array([[]])
  
  Pe=np.array([[394.20560747663563, 408.7929050665396 , 419.132709901089  ,
          398.95097406721044, 403.81198021076113, 430.00914784982064,
          424.50127213826016, 453.54817733128607, 441.4651085668709 ,
          447.42507960635163, 413.8982415602072 , 390.3025816600353 ]])
              
  
  C1 = nan
  for i in J[0]:
      Pe = np.insert(Pe, i, [C1], axis=1)
  print(&quot;Pe =&quot;, [Pe])
  
  for i in range(0,len(Pe)):
      Max=max(max(Pe[i]), max(Pe[i]))
      Min=min(min(Pe[i]), min(Pe[i]))
      
      arMax.append(Max)
      Max=np.array(arMax)
      
      arMin.append(Min)
      Min=np.array(arMin)
  
  a=min(Min)
  b=max(Max)
  
  print(&quot;a =&quot;,a)
  print(&quot;b =&quot;,b)
  
  
  Amax= math.ceil(b)
  Amin= math.floor(a)
  print(Amax, Amin)
  
  color = cm.get_cmap('Dark2')
  norm = Normalize(vmin=Amin, vmax=Amax)
  color_list = []
  for i in range(len(Pe[0])):   
      color_list.append(color(((Pe[0,i])-Amin)/(Amax-Amin)))
      
  id = 0
  for j in range(0, n):
      for k in range(n-1):
          aPe.hlines(200+200*(n-j-1)+5*n, 200*(k+1)+5*n, 200*(k+2)+5*n, zorder=0, colors=color_list[id])
          id += 1
  
      for i in range(0, n):
          rect = mpl.patches.Rectangle((200+200*i, 200+200*j), 10*n, 10*n, linewidth=1, edgecolor='black', facecolor='black')
          aPe.add_patch(rect)
          if j &lt; n-1:
              aPe.vlines(200+200*i+5*n, 200*(n-1-j)+5*n, 200*(n-j)+5*n, zorder=0, colors=color_list[id])
              id += 1
  
  cb = fig.colorbar(cm.ScalarMappable(cmap=color, norm=norm), ticks=np.arange(Amin, Amax+len(color.colors), len(color.colors)))
  cb.set_ticks(np.arange(Amin, Amax+1, (Amax-Amin)/8).astype(np.int64))
  cb.set_label(&quot;Entry pressure (N/m$^{2}$)&quot;)
  aPe.set_xlim(left = 0, right = 220*n)
  aPe.set_ylim(bottom = 0, top = 220*n)
  plt.axis('off')
  plt.show()
  </code></pre>
  <p>The current output is</p>
  <p><a href="https://i.stack.imgur.com/pkc6g.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/pkc6g.png" alt="enter image description here" /></a></p>
  <p>The expected output is</p>
  <p><a href="https://i.stack.imgur.com/i56X3.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/i56X3.png" alt="enter image description here" /></a></p>