Skip to content

Commit

Permalink
Merge pull request matplotlib#6606 from Copper-Head/fix-hinton-demo
Browse files Browse the repository at this point in the history
Fix hinton demo
  • Loading branch information
jenshnielsen authored Jun 19, 2016
2 parents f8ac8f6 + 9a6cec0 commit 1caf775
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions examples/specialty_plots/hinton_demo.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ def hinton(matrix, max_weight=None, ax=None):
ax = ax if ax is not None else plt.gca()

if not max_weight:
max_weight = 2**np.ceil(np.log(np.abs(matrix).max())/np.log(2))
max_weight = 2 ** np.ceil(np.log(np.abs(matrix).max()) / np.log(2))

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

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

0 comments on commit 1caf775

Please sign in to comment.