Guest User

Untitled

a guest
Jul 15th, 2018
104
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.39 KB | None | 0 0
  1. import numpy as np
  2. x=np.loadtxt("foo.csv", delimiter="t")
  3. l_vertices=['77', '364', '295', '221', '465', '1881', '1076', '310', '156', '464', '184', '741', '262', '1811', '1190', '440', '490', '867', '974', '1657', '621', '39', '46', '209', '1674', '1677', '1260', '183', '1411', '1120', '444', '1492', '1168', '598', '859', '322', '325', '595', '366', '782', '71', '1422', '251', '954', '778', '642', '945', '605', '205', '178', '236', '628', '647', '21', '1902', '210', '45', '107', '172', '257', '498', '494', '1644', '261', '1809', '303', '1312', '830', '1906', '242', '845', '1668', '852', '1409', '970', '254', '677', '1684', '1421', '791', '117', '1412', '1440', '1407', '548', '432', '777', '425', '909', '1852', '995', '1202', '185', '1347', '1618', '1493', '1629', '965', '74', '712', '880', '975', '99', '115', '220', '656', '1108', '216', '269', '1889', '1159', '578', '480', '1622', '312', '141', '1049', '1856', '1212', '1214', '15', '58', '232', '1464', '1513']
  4. from matplotlib.ticker import MaxNLocator
  5. import matplotlib.ticker as ticker
  6. from matplotlib.path import Path
  7. import matplotlib.patches as patches
  8.  
  9. fig = plt.figure(figsize=(28, 28))
  10. ax = fig.add_subplot(111)
  11. img=ax.imshow(x, interpolation="nearest", cmap=plt.cm.coolwarm, aspect='auto',origin="lower")
  12. xs=l_vertices
  13. print(l_vertices)
  14. f = lambda l: (f(l[1:]) + l[:1] if l else [])
  15. ys=f(l_vertices)
  16. ax.set_xticklabels(xs,fontsize='small')
  17. ax.set_yticklabels(ys,fontsize='small')
  18. ax.xaxis.set_major_locator(MaxNLocator(len(xs)))
  19. ax.yaxis.set_major_locator(MaxNLocator(len(ys)))
  20. ax.xaxis.tick_top()
  21. ax.set_yticks(my_yticks[1:])
  22. ax.set_xticks(my_yticks[1:])
  23. ##Make_block
  24. for i in range(Num_blocks):
  25. nmin=dbm[str(i)][0]
  26. nhymin=ys.index(nmin)-0.5
  27. nhxmin=xs.index(nmin)-0.5
  28. print(nmin,nhmin)
  29. nmax=dbm[str(i)][-1]
  30. nhymax=ys.index(nmax)+0.5
  31. nhxmax=xs.index(nmax)+0.5
  32. verts = [
  33. (nhxmin, nhymin), # left, bottom
  34. (nhxmin, nhymax), # left, top
  35. (nhxmax, nhymax), # right, top
  36. (nhxmax, nhymin), # right, bottom
  37. (0., 0.), # ignored
  38. ]
  39. codes = [Path.MOVETO,
  40. Path.LINETO,
  41. Path.LINETO,
  42. Path.LINETO,
  43. Path.CLOSEPOLY,
  44. ]
  45. path = Path(verts, codes)
  46. patch = patches.PathPatch(path, facecolor='none', lw=2)
  47. ax.add_patch(patch)
  48. ##
  49. fig.colorbar(img, ax=ax)
  50. plt.setp( ax.xaxis.get_majorticklabels(), rotation=90 )
  51. plt.show()
Add Comment
Please, Sign In to add comment