Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 1caf775

Browse files
authored
Merge pull request #6606 from Copper-Head/fix-hinton-demo
Fix hinton demo
2 parents f8ac8f6 + 9a6cec0 commit 1caf775

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

examples/specialty_plots/hinton_demo.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ def hinton(matrix, max_weight=None, ax=None):
1717
ax = ax if ax is not None else plt.gca()
1818

1919
if not max_weight:
20-
max_weight = 2**np.ceil(np.log(np.abs(matrix).max())/np.log(2))
20+
max_weight = 2 ** np.ceil(np.log(np.abs(matrix).max()) / np.log(2))
2121

2222
ax.patch.set_facecolor('gray')
2323
ax.set_aspect('equal', 'box')
@@ -26,7 +26,7 @@ def hinton(matrix, max_weight=None, ax=None):
2626

2727
for (x, y), w in np.ndenumerate(matrix):
2828
color = 'white' if w > 0 else 'black'
29-
size = np.sqrt(np.abs(w))
29+
size = np.sqrt(np.abs(w) / max_weight)
3030
rect = plt.Rectangle([x - size / 2, y - size / 2], size, size,
3131
facecolor=color, edgecolor=color)
3232
ax.add_patch(rect)

0 commit comments

Comments
 (0)