Strange behavior on subplots with surf
Show older comments
Today I noticed a very strange behavior in a rather complex creation of a figure. To see the actual problem, I broke down the code to the essential parts: I create a figure with two subplots in one figure. But whenever I add a surface plot to the second subplot (instead of a normal 2D plot) the properties of the first subplot change. Please run the following code, compare the figures to see the differences:
x=1:20;
y1=randn(20,1);
y2=ones(20,1);
figure;
subplot(2,2,[1,2]);
plot(x,y1,x,y1);hold on;
plot(x,y2,'--b','LineWidth',2); hold off;
subplot(2,2,[3,4]);
surf(x,x,y1*y1','LineStyle','none');
figure;
subplot(2,2,[1,2]);
plot(x,y1,x,y1); hold on;
plot(x,y2,'--b','LineWidth',2); hold off ;
subplot(2,2,[3,4]);
plot(x,y1);
Is there an explantion for this change (especially for the dashed line)? How can I change the properties of the second figure to the unintended and changed properties of figure 1?
I use Matlab R2013b! Thanks for the support!
2 Comments
No klew...it acts the same way in R2012b(*), btw, so it's not the new graphics engine.
For some reason the lines are rendered differently despite style and width parameters being the same. I went side-by-side and retrieved the handles to the two lines and set the properties manually to a range of line widths and the rendering still isn't the same between the two. I could observe no properties that were different that are visible.
BTW, why use
subplot(2,2,[1,2]);
instead of the syntactically simpler
subplot(2,1,1);
for full-width, two-high suplots??
ADDENDUM
(*) Just out of curiosity, I tried the earliest version I have installed (R11). The difference isn't quite as noticeable but they're still different. With it the apparent width is almost indistinguishable between the two but there's a notable difference in the length of the dashed line segments between the two.
Really, really, bizzaro!!! Be interesting to hear what TMW has to say on this one...
Sven
on 20 Feb 2015
Accepted Answer
More Answers (0)
Categories
Find more on Graphics Performance 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!