Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 1caf775

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

File tree

Expand file treeCollapse file tree

1 file changed

+2
-2
lines changed
Filter options
Expand file treeCollapse file tree

1 file changed

+2
-2
lines changed

‎examples/specialty_plots/hinton_demo.py

Copy file name to clipboardExpand all lines: examples/specialty_plots/hinton_demo.py
+2-2Lines 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 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.