Odd Subplot Behavior - Script interpreter bug?

1 view (last 30 days)
Wick
Wick on 28 Jun 2018
Commented: Wick on 28 Jun 2018
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.
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.
Finally, if I let jj advance to 3 (for jj=1:3) The bottom plot in the middle column also gets ruined.
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 Comments
Jason Whitfield
Jason Whitfield on 28 Jun 2018
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.
Wick
Wick on 28 Jun 2018
It's coming from a code that loads a bunch of data from a lookup table with lots of custom functions so I'll see if I can reproduce this with a smaller block of data and code and post that.
The really weird thing is that when I copy/paste the code into the interpreter the plots come out fine. That's what leads me to believe it's not a variables definition thing.

Sign in to comment.

Answers (0)

Categories

Find more on Specifying Target for Graphics Output in Help Center and File Exchange

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!