Hinton Diagram Using 3 matrix

조회 수: 2 (최근 30일)
Tahereh Aram
Tahereh Aram 2015년 3월 10일
편집: Tahereh Aram 2020년 9월 5일
H

답변 (1개)

Christiaan
Christiaan 2015년 3월 11일
Hello Tahereh,
In your question you defined three matrixes x(i), y(i) and z(i). However a matrix is an 2D (or higher) array, and therefore cannot be possible. Please refine your question if nessesary.
In file below, i made a code for you (constructed from two files (1) and (2) in the file exchange) how to make an Hinton diagramm from a matrix w:
clc;clear all;close all;
w = magic(5)
w = flipud(w);
[nrows, ncols] = size(w);
scale = 0.45*sqrt(abs(w)/max(max(abs(w))));
scale = scale(:);
color = 0.5*(sign(w(:)) + 3);
delx = 1; dely = 1;
[X, Y] = meshgrid(0.5*delx:delx:(ncols-0.5*delx), 0.5*dely:dely:(nrows-0.5*dely));
xtemp = X(:); ytemp = Y(:);
xvals = [xtemp-delx*scale, xtemp+delx*scale, ...
xtemp+delx*scale, xtemp-delx*scale];
yvals = [ytemp-dely*scale, ytemp-dely*scale, ...
ytemp+dely*scale, ytemp+dely*scale];
xmax = 640; ymax = 480;
% Offset bottom left hand corner
x01 = 40; y01 = 40; x02 = 80; y02 = 80;
% Need to allow 5 pixels border for window frame: but 30 at top
border = 5; top_border = 30;
ymax = ymax - top_border; xmax = xmax - border;
% Try to preserve aspect ratio approximately
if (8*size(w, 1) < 6*size(w, 2))
delx = xmax; dely = xmax*size(w, 1)/(size(w, 2));
else
delx = ymax*size(w, 2)/size(w, 1); dely = ymax;
end
h = figure('Color', [0.5 0.5 0.5], ...
'Name', 'Hinton diagram', ...
'NumberTitle', 'off', ...
'Colormap', [0 0 0; 1 1 1], ...
'Units', 'pixels', ...
'Position', [x01 y01 delx dely]);
set(gca, 'Visible', 'off', 'Position', [0 0 1 1]);
hold on
patch(xvals', yvals', color', 'Edgecolor', 'none');
axis equal;
Good luck! Christiaan

카테고리

Help CenterFile Exchange에서 Data Distribution Plots에 대해 자세히 알아보기

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by