Manage and produce subplots
3 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
I have around 160 plots that are generated in a for loop. The number of plots might vary based on the inputs they are more than 100 so I need to manage them.
I was wondering if you have any suggestion managing/presenting this number of plots? If I want to use subplots (3*3 for example) how can I manage to do it automatically so I dont need to give the location of each subplot? since e.g. I want to have 9 plots in one subplot, I need to have 18 distinct subplot. e.g. when each loop is called, the plot is placed next to the previous plot.
The for loop that I use is:
for jjj=1:length(struct)
if jjj==1
rowidx = KsTable.k_name == KsTable.k_name(jjj) ;
x=KsTable.k_value(rowidx);
y=KsTable.Mean.prolif(rowidx);
figure
plot(x,y,'-rs','LineWidth',2,...
'MarkerEdgeColor','k',...
'MarkerFaceColor','g',...
'MarkerSize',5)
xlabel(KsTable.k_name(jjj))
ylabel(strrep('Mean_Prolif','_','\_'))
%Plot derivative:
x=KsTable.deltax(rowidx);
y=KsTable.prolif(rowidx);
figure
plot(x,y,'-rs','LineWidth',2,...
'MarkerEdgeColor','k',...
'MarkerFaceColor','g',...
'MarkerSize',5)
xlabel("delta x" + KsTable.k_name(jjj))
ylabel(strrep('prolif_mean','_','\_'))
elseif KsTable.k_name(jjj)~= KsTable.k_name(jjj-1)
rowidx = KsTable.k_name == KsTable.k_name(jjj) ;
x=KsTable.k_value(rowidx);
y=KsTable.Mean.prolif(rowidx);
figure
plot(x,y,'-rs','LineWidth',2,...
'MarkerEdgeColor','k',...
'MarkerFaceColor','g',...
'MarkerSize',5)
xlabel(KsTable.k_name(jjj))
ylabel(strrep('Mean_Prolif','_','\_'))
%Plot derivative:
x=KsTable.deltax(rowidx);
y=KsTable.prolif(rowidx);
figure
plot(x,y,'-rs','LineWidth',2,...
'MarkerEdgeColor','k',...
'MarkerFaceColor','g',...
'MarkerSize',5)
xlabel("delta x" + KsTable.k_name(jjj))
ylabel(strrep('prolif_mean','_','\_'))
end
end
5 comentarios
Adam
el 22 de Oct. de 2019
p = mod( plotNumber, 9 )
should work fine. Unless you fill them in some zany order the first place that is empty should be the next plot in the list.
I don't know how you are planning to control your figures for each having 3x3 plots on, but if you are doing that anyway then determining p is trivial.
Respuestas (1)
Rik
el 22 de Oct. de 2019
It is not too dificult to keep track of you p in a loop:
p=0;
for n=1:9
p=p+1;%(p=n; would also work for this example)
subplot(3,3,p)
plot(rand(10,2))
title(sprintf('%d',n))
end
3 comentarios
Steven Lord
el 22 de Oct. de 2019
So after you create the 9th subplot in your figure, create a new figure and reset the counter of which subplot you want to contain your next plot to 1.
Ver también
Categorías
Más información sobre Subplots en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!