Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import numpy as np
- x=np.loadtxt("foo.csv", delimiter="t")
- 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']
- from matplotlib.ticker import MaxNLocator
- import matplotlib.ticker as ticker
- from matplotlib.path import Path
- import matplotlib.patches as patches
- fig = plt.figure(figsize=(28, 28))
- ax = fig.add_subplot(111)
- img=ax.imshow(x, interpolation="nearest", cmap=plt.cm.coolwarm, aspect='auto',origin="lower")
- xs=l_vertices
- print(l_vertices)
- f = lambda l: (f(l[1:]) + l[:1] if l else [])
- ys=f(l_vertices)
- ax.set_xticklabels(xs,fontsize='small')
- ax.set_yticklabels(ys,fontsize='small')
- ax.xaxis.set_major_locator(MaxNLocator(len(xs)))
- ax.yaxis.set_major_locator(MaxNLocator(len(ys)))
- ax.xaxis.tick_top()
- ax.set_yticks(my_yticks[1:])
- ax.set_xticks(my_yticks[1:])
- ##Make_block
- for i in range(Num_blocks):
- nmin=dbm[str(i)][0]
- nhymin=ys.index(nmin)-0.5
- nhxmin=xs.index(nmin)-0.5
- print(nmin,nhmin)
- nmax=dbm[str(i)][-1]
- nhymax=ys.index(nmax)+0.5
- nhxmax=xs.index(nmax)+0.5
- verts = [
- (nhxmin, nhymin), # left, bottom
- (nhxmin, nhymax), # left, top
- (nhxmax, nhymax), # right, top
- (nhxmax, nhymin), # right, bottom
- (0., 0.), # ignored
- ]
- codes = [Path.MOVETO,
- Path.LINETO,
- Path.LINETO,
- Path.LINETO,
- Path.CLOSEPOLY,
- ]
- path = Path(verts, codes)
- patch = patches.PathPatch(path, facecolor='none', lw=2)
- ax.add_patch(patch)
- ##
- fig.colorbar(img, ax=ax)
- plt.setp( ax.xaxis.get_majorticklabels(), rotation=90 )
- plt.show()
Add Comment
Please, Sign In to add comment