The function Hinton_plot.m works in Matlab or Octave to display a real or complex matrix using a Hinton diagram (original idea published here). At each position in the matrix the marker area is proportional to the absolute value of the matrix element, which allows a wide range of values to be displayed and readily interpreted. If the matrix is real and positive, the colour of all markers is the same. If not, the phase of each element modifies the colour of the corresponding marker. The advantages of Hinton diagrams over traditional colour-mapped display (e.g., imagesc) are:
- differences in magnitude of the matrix elements are more readily interpreted from the size of the markers as opposed to colour or grayscale differences
- if complex, the phase is also visualized (as a colour), which is impossible with traditional display
Examples shown below include 8x8 noise correlation and covariance matrices which are often used in MR image reconstruction from coil arrays.
Similar functionality is available in R's corrplot and in Python's matplotlib.
I hope you find this useful.
Hinton_plot(A);
Hinton_plot(A,marker);
S = Hinton_plot(A,marker);
Where:
A
is the matrix to be displayed.marker
(optional) specifies the marker type similarly to other graphical commands like plot. The default marker is a circle.
The function returns a handle (S
) to a scatter object.
A=2*rand(50)-1;
s=Hinton_plot(A,'s');
set(s,'markeredgecolor','k')
Using square markers ('s' ): |
With imagesc only magnitude can be displayed: |
---|---|
Notice how differences in variance (along the diagonal) are readily identified and Hermitian symmetry is verified by looking at the phase colours.
Markers are default circles ('o'
).
Using diamonds ('d' ): |
|
---|---|
Nicola De Zanche
Software code is licensed under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or any later version.
All other original content in this repository (including this README file) is licensed under a Creative Commons Attribution-NoDerivatives 4.0 International License.