Plotting 16 plots in one figure using handle graphics
2 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Maria Galle
am 3 Dez. 2020
Kommentiert: Ameer Hamza
am 8 Dez. 2020
I'm trying to plot 16 plots in one figure window to make a 4x4 grid using handle graphics and NOT using subplot. I'm trying to use a for loop to make the plots. I'm getting 16 of the same plot instead of 16 different plots (magic(5), magic(6),magic(7)...etc).
k = 4;
dim = 0.8/k-0.05;
axs = gobjects(k);
for i = 1:k
for j = 1:k
for N=5:20
data = magic(N);
axs(i,j) = axes();
zp=imagesc(data);
xloc = interp1([1, k], [0.1, 0.9-dim], j);
yloc = interp1([1, k], [0.9-dim, 0.1], i);
axs(i,j).Position = [xloc yloc dim dim];
end
end
end
0 Kommentare
Akzeptierte Antwort
Ameer Hamza
am 3 Dez. 2020
Try this
n = 4;
dim = 0.8/n-0.05; % considering that the axes will go from 0.1 to 0.9 in figure coordinates
% and leaving space between axes
axs = gobjects(n);
for i = 1:n
for j = 1:n
axs(i,j) = axes();
xloc = interp1([1, n], [0.1, 0.9-dim], j);
yloc = interp1([1, n], [0.9-dim, 0.1], i);
axs(i,j).Position = [xloc yloc dim dim];
end
end
4 Kommentare
Ameer Hamza
am 8 Dez. 2020
Try this code
n = 4;
dim = 0.8/n-0.05; % considering that the axes will go from 0.1 to 0.9 in figure coordinates
% and leaving space between axes
axs = gobjects(n);
N = 5;
for i = 1:n
for j = 1:n
axs(i,j) = axes();
xloc = interp1([1, n], [0.1, 0.9-dim], j);
yloc = interp1([1, n], [0.9-dim, 0.1], i);
axs(i,j).Position = [xloc yloc dim dim];
M = magic(N);
N = N+1;
imagesc(M)
end
end
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu Annotations finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!