title: How to solve error index out of bounds for axis 0?
body: <p>There are multiple polygons for which I want to change the color and width of a specific edge. There is no problem with polygon initializing (Fig.1), but when I want to change the color and width of one edge of polygons in the for-loop (Fig.2 ) it raised error</p>
  
  <pre class="lang-none prettyprint-override"><code>File "C:\Users\Initi__BC_1024_E2.py", line 41, in &lt;module&gt;  
      vertex[4,i,0,:] = one_coord[j][-1][:]  
  
  IndexError: index 4 is out of bounds for axis 0 with size 4'
  </code></pre>
  
  <p>Fig 1. Preliminary polygon(Input)</p>
  
  <p><a href="https://i.stack.imgur.com/YcylLm.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/YcylLm.jpg" alt="The preliminary polygon"></a></p>
  
  <p>Fig 2. Final Polygon (output)</p>
  
  <p><a href="https://i.stack.imgur.com/ruXjIm.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/ruXjIm.jpg" alt="Final Polygon (output)"></a></p>
  
  <pre class="lang-py prettyprint-override"><code>import numpy as np
  import matplotlib.pyplot as plt
  
  pixels = 600
  my_dpi = 100
  num_geo=4
  
  one_coord = np.array([[[-150, -200], [300, -200], [300, 0], [150, 200], [-150, 200]],
                    [[-300, -200], [200, -300], [200, -50], [200, 300], [-150, 200]],
                    [[-140, -230], [350, -260], [350, 0], [140, 200], [-180, 220]],
                    [[-180, -240], [370, -270], [370, 0], [170, 200], [-190, 230]]])
  
  for i in range(4):
      geo =one_coord[i, :, :]
      print(one_coord[i])
      fig = plt.figure(num_geo, figsize=(pixels/my_dpi, pixels/my_dpi), 
                       facecolor='k', dpi=my_dpi)  
      plt.axes([0,0,1,1])
      rectangle = plt.Rectangle((-300, -300), 600, 600, fc='k')
      plt.gca().add_patch(rectangle)
      polygon = plt.Polygon(one_coord[i],color='w')
      plt.gca().add_patch(polygon)
      plt.axis('off')
      plt.axis([-300,300,-300,300])
      plt.close()
      vertex_number = 5
  
  vertex = np.zeros((4,vertex_number,2, 2))
  
  for j in range(num_geo):
      one_coord[j]
  
  for k in range(vertex_number-1):   #rang(4), (0,1,2,3)
      vertex[j] = one_coord[j][k:k+2]  #(0:2) to (3:5)
      vertex[j,4,0,:] = one_coord[j][-1][:]
      vertex[j,4,1,:] = one_coord[j][0][:]
  
      plt.plot( vertex[j,:,0], vertex[j,:,1], linewidth=5, color='r')
  
      plt.savefig('figureBc/%d.jpg' % i, dpi=my_dpi)
      plt.close()
  </code></pre>