In the mpl site, i found the an example code called hinton_demo to plot weighted matrix in the following link.
I used the same script (attached test.py) making a slight modification in the following section of the code pasted below. I just included more color range and modified the size as np.sqrt(np.abs(w))/5.
However when i run the script with test data (attached test.dat), i found that the size of the square and color are not matching. For instance the size of the squares at position
4,3 and 7,6 are small but the color (black) is not relevant to the size. I am not getting what is going wrong. Kindly help to resolve the problem.
The script and test data are attached.
Section of the code modified
for (x,y),w in np.ndenumerate(W): if w > 0: color = 'white' else: color = 'black' size = np.sqrt(np.abs(w)) rect = Rectangle([x - size / 2, y - size / 2], size, size, facecolor=color, edgecolor=color) ax.add_patch(rect)
test.py (1.52 KB)
test.dat (504 Bytes)