Hinton Diagram Using 3 matrix

2 visualizaciones (últimos 30 días)
Tahereh Aram
Tahereh Aram el 10 de Mzo. de 2015
Editada: Tahereh Aram el 5 de Sept. de 2020
H

Respuestas (1)

Christiaan
Christiaan el 11 de Mzo. de 2015
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

Categorías

Más información sobre Data Distribution Plots en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by