Plotting 16 plots in one figure using handle graphics
2 次查看(过去 30 天)
显示 更早的评论
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 个评论
采纳的回答
Ameer Hamza
2020-12-3
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 个评论
Ameer Hamza
2020-12-8
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
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Annotations 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!