Plotting 16 plots in one figure using handle graphics
2 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
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 commentaires
Réponse acceptée
Ameer Hamza
le 3 Déc 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 commentaires
Ameer Hamza
le 8 Déc 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
Plus de réponses (0)
Voir également
Catégories
En savoir plus sur Annotations dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!