Fantastic Mr Fox
Fantastic Mr Fox

Reputation: 33864

Axis equal fail matlab

I have an interesting problem in matlab. If i run the following code in a script and i run it by selecting it and pressing F9:

figure
subplot(4, 4, [1 2 5 6 9 10]);
plotGrid(spin1HGD, 2);    % A function to plot a grid, 
                          % essentially a bunch of patches. 
campos([27.8504  -39.0203   71.3373]);
axis equal

I get the following figure:

enter image description here

now if i immediately run axis equal, it actually does it:

enter image description here

Here is a screenshot of my matlab terminal:

enter image description here

So i am definitely running axis equal at the end of the script and then I am having to actually manually run it for it to work.

Annoyingly, I cant reproduce it in anything but this code? What is the deal?

Upvotes: 3

Views: 735

Answers (1)

Tokkot
Tokkot

Reputation: 1215

As suggested, adding drawnow before axis equal will fix this problem.

To reproduce the issue, run this code in a script:

figure
subplot(4, 4, [1 2 5 6 9 10]);
patch(rand(3), rand(3), [1 0 1])
campos([27.8504  -39.0203   71.3373]);
% drawnow 
axis equal

then type 'axis equal' in the command window and notice that the plot changes.

Upvotes: 2

Related Questions