-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathplotHeatMap.py
More file actions
34 lines (23 loc) · 1.04 KB
/
plotHeatMap.py
File metadata and controls
34 lines (23 loc) · 1.04 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
import matplotlib.pyplot as plt
import matplotlib.colors as colors
import numpy as np
import pandas as pd
class plotHeatMap:
def __init__ (self , sparse_singer_data):
plt.figure(1)
plt.switch_backend('TkAgg') #TkAgg (instead Qt4Agg)
bounds = np.array([0, 100, 200, 300, 400, 500, 600, 700, 1000, 2000, 3000, 4000, 5000, 10000, 25000, 500000]) #MRS intervals
norm = colors.BoundaryNorm(boundaries=bounds, ncolors=256)
fig = plt.figure()
ax = fig.add_subplot(111)
cax = ax.matshow(sparse_singer_data, interpolation='nearest',cmap=plt.get_cmap('RdBu_r'), norm=norm)
cb = fig.colorbar(cax)
cb.set_label('Number Of Plays')
# cax.axes.get_xaxis().set_visible(False)
# cax.axes.get_yaxis().set_visible(False)
ax.set_xlabel('Users', fontsize=12, color='Blue')
ax.set_ylabel('Artists', fontsize=12, color='Green')
mng = plt.get_current_fig_manager()
mng.window.state('zoomed')
def show(self):
plt.show();