Advertisement
Guest User

Untitled

a guest
Feb 21st, 2020
96
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.82 KB | None | 0 0
  1. QUESTION 4:
  2.  
  3. The size of the square is of size 10. So assuming zero indexing,
  4. vertical side1 (column Index = 5): row index from 5 to 14
  5. vertical side1 (column Index = 14): row index from 5 to 14
  6. horizontal side1 (row Index = 5): column index from 5 to 14
  7. horizontal side2 (row Index = 14): column index from 5 to 14
  8.  
  9. Note:
  10. while indexing, data_new[a:b,c] denotes,
  11. row index: a to b-1
  12. column index: c
  13.  
  14. Similarly data_new[a,b:c] denotes,
  15. row index: a
  16. column index: b to c-1
  17.  
  18. Code:
  19.  
  20. import matplotlib.pyplot as plt
  21. import numpy as np
  22.  
  23. size_1 = 20
  24. size_2 = 20
  25. data_new = np.random.random((size_1,size_2))
  26.  
  27. data_new[5:15,5] = 4
  28. data_new[5:15,14] = 4
  29. data_new[5,5:15] = 4
  30. data_new[14,5:15] = 4
  31.  
  32. fig = plt.figure(figsize=(10,10))
  33. plt.imshow(data_new)
  34. plt.colorbar()
  35. plt.show()
  36.  
  37. OUTPUT:
  38. https://ibb.co/q7ZvVRh
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement