Skip to content
Snippets Groups Projects
Commit 86efb314 authored by Ivo Peterek's avatar Ivo Peterek
Browse files

ENH: runing heatmap module #5

parent 18223dc1
No related branches found
No related tags found
No related merge requests found
......@@ -6,6 +6,7 @@
#
# WARNING! All changes made in this file will be lost!
from modules import data_plot
from modules import heatmap
from PyQt5 import QtCore, QtGui, QtWidgets
......@@ -39,11 +40,15 @@ class Ui_MainMenu(object):
QtCore.QMetaObject.connectSlotsByName(MainMenu)
self.pushButton_plot.clicked.connect(self._plot)
self.pushButton_heatmap.clicked.connect(self._heatmap)
def _plot(self):
main = data_plot.Window()
main.show()
def _heatmap(self):
heatmap.draw_heatmap()
def retranslateUi(self, MainMenu):
_translate = QtCore.QCoreApplication.translate
MainMenu.setWindowTitle(_translate("MainMenu", "Main menu"))
......
#!/usr/bin/env python3
import matplotlib
from packaging import version
if version.parse(matplotlib.__version__) < version.parse("2.0.3"):
raise Exception("Matplotlib version must be >= 2.0.3, while yours is {}!".format(matplotlib.__version__))
#matplotlib.use('Qt5Agg')
import matplotlib.pyplot as pp
pp.switch_backend('Qt5Agg')
import numpy as np
import matplotlib.colors as mpc
#import plotly.graph_objs as go
#import plotly
import seaborn as sb; sb.set()
#import os
data = None # TODO handling data as parameter
def onclick(event):
idx = int(np.floor(event.xdata))
idy = int(np.floor(event.ydata))
print('Indices and content of current cell [{},{}]: {}'.format(idx,idy,data[idy+1,idx]))
def draw_heatmap():
C = np.loadtxt('../input/colormap.txt')
cm = mpc.ListedColormap(C/255.0)
'''data = np.array([[1, 2, 3, 4, 5],
[-3, -1, 1, 3, 5],
[2, 3, 5, 7, 13],
#[9, 1, -2.5, 2, 8],
#[12,1,2,-4,4],
#[1,1,1,1,1],
#[1,1,1,1,1],
[8,8,8,8,8],
[-6,1,1,1,1]])'''
dict_data = np.load('../input/data.npy').item()
x = len(dict_data['0'])
y = len(dict_data['0']['2.5']['avgProgramStart'])
k = list(dict_data['0'].keys())
k.sort()
data = np.zeros([y,x])
ky = ['2.0','2.1','2.2','2.3','2.4','2.5']
j = -1
for each in k:
j = j + 1
for i in range(0,y):
data[-i-1][j] = dict_data['0'].get(each)['avgProgramStart'][i][1][0]
print(data[0,:])
cell_font_size = 14
cell_height = 7/360*cell_font_size
cell_width = 4.5*cell_height
marg_top = 0.5
marg_bottom = 0.5
marg_left = 1
marg_right = 0.5
cells_in_row = x
cells_in_column = y
figwidth= cell_width*cells_in_row+marg_left+marg_right
figheight = cell_height*cells_in_column+marg_top+marg_bottom
fig = pp.figure(figsize=(figwidth, figheight))
fig.subplots_adjust(bottom =marg_bottom/figheight, top=1.-marg_top/figheight, left=marg_left/figwidth, right=1.-marg_right/figwidth)
cid = fig.canvas.mpl_connect('button_press_event', onclick)
sb.set_context('talk')
hm = sb.heatmap(data, annot=True, annot_kws = {"size": cell_font_size}, fmt=".3f", cmap=cm, square=False, cbar=False)
hm.xaxis.tick_top()
hm.set_xticklabels(k, ha = 'center')
#pp.set_xticklabels
hm.set_yticklabels(ky, va = 'center')
pp.yticks(rotation=0)
pp.xlabel('Frequency [GHz (uncore)]')
pp.ylabel('Frequency [GHz (core)]')
pp.show()
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment