October 2018
Beginner to intermediate
676 pages
18h 30m
English
The following code block defines the function and makes a call to the function to plot the Hinton diagram:
matrix = np.asarray((pd.read_excel('weight_matrix.xlsx')))
fig, ax = plt.subplots()
ax.patch.set_facecolor('gray')ax.set_aspect('equal', 'box')ax.xaxis.set_major_locator(plt.NullLocator())ax.yaxis.set_major_locator(plt.NullLocator())
max_weight = 2 ** np.ceil(np.log(np.abs(matrix).max()) / np.log(2))for (x, y), w in np.ndenumerate(matrix): color = 'white' if w > 0 else 'black' size = np.sqrt(np.abs(w) / max_weight) rect = plt.Rectangle([x - size / 2, y - size / 2], size, ...Read now
Unlock full access