Subplot ID in a loop where k> number of plot locations for a single page
1 次查看(过去 30 天)
显示 更早的评论
Hi, This is a tricky one for me to explain. I have q files, and want to subplot them on a page with 4 locations. Due to considerations for how the figures/pages will be looked at in a pdf I am using a (2,4,q) subplot and plotting a distribution in (2,2,1:2) etc. It would be easier to just have (2,2,q) but they would not look so good in the final pdf.
For q being no higher than 4 I use
subplot(PlotsPerPage/2,PlotsPerPage,[q+q-1, q+q])
which works nicely. But when q>4 it falls over. I think my problem is more of a math issue than matlab but I am hoping that there will be a way to do take use of a matlab function maybe in a way I am not aware of. I can do this longhand by having if statements for when q=5:8 or q=9:12 etc but would like to avoid that as I can see q going to a very high number by the end of the year.
2 个评论
Jan
2017-4-10
I'm confused by the question. What does "using a (2,4,q) subplot and plotting a distribution in (2,2,1:2) etc." mean? Do you really mean "subplot(PlotsPerPage/2,PlotsPerPage, [q+q-1, q+q])"? Then the pages contains more plots then PlotsPerPage and for q = 2 you get the position [3, 4]. Sorry, I cannot follow you.
You currently have:
subplot(2,4,q)
What fails for q > 4? Do you want to display 8 diagrams per page? What happens and what do you want to happen?
采纳的回答
Jan
2017-4-10
Do you mean:
q = 1:10
qq = mod(q - 1, 4) + 1
>> 1 2 3 4 1 2 3 4 1 2
Then the values of qq are restricted to 1:4. I assume you have to open a new figure when qq is 1 - as shown in your other thread.
3 个评论
Jan
2017-4-11
If "subplot(PlotsPerPage/2,PlotsPerPage,[q+q-1, q+q])" works reliably, then use in the 2nd loop:
for q = 5:8
qq = mod(q - 1, 4) + 1;
subplot(PlotsPerPage/2,PlotsPerPage,[qq+qq-1, qq+qq])
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Subplots 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!