Odd Subplot Behavior - Script interpreter bug?
1 次查看(过去 30 天)
显示 更早的评论
I've got a script that produces some plots. It's nothing fancy. I haven't included all the variable definitions in the code snippet below because they're not important. But you can see, I'm just using subplot and plot to make a bunch of plots.
If I just consider one loop (for jj = 1:1) I get the following set of plots.
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/191531/image.png)
If I allow jj to advance to 2 (for jj=1:2) I get this next set of images. Notice that the bottom plot in the first column is changed (and the axes go all whacky) but the second loop didn't change any of the first column plots.
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/191532/image.png)
Finally, if I let jj advance to 3 (for jj=1:3) The bottom plot in the middle column also gets ruined.
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/191533/image.png)
Now, here's the really weird part. If I change jj by hand and then copy/paste the same commands from the script editor into the interpreter I don't see any odd behavior at all. New columns are added and previous columns remain unchanged. I'm attaching the 'fig' file for the last plot as well as a snippet of the code I'm using.
Thanks in advance for anyone that can give me a workaround or (better yet) a solution!
I saw the same behavior in 2017b and 2018a. I'm using Windows 10 64-bit on an AMD Threadripper cpu.
for jj = 1:1
% variable_definitions_here
subplot(4,3,jj)
plot(xinside,G,'b-',xoutside,G,'k:')
subplot(4,3,jj+3)
plot(xpatch,ypatch);
subplot(4,3,jj+6)
plot(x,y,'-*');
end
3 个评论
Jason Whitfield
2018-6-28
I tried to reproduce this, but was unsuccessful. However, when I open your figure and run this code, it outputs [90, 45]. So, something is changing the views on your subplots.
sp = subplot(4, 3, 7);
disp(sp.View);
Could you post your full code? It's possible that something is happening in the variable definitions.
回答(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!