2

I'm looking for a way to export anti-aliased graphics containing lines and "surf" at the same time.

With HG2, the "plot" lines are anti-aliased by default but the anti-aliasing is switched off once I insert a "surf". The closest I could get was by using "export_fig" but it's not exporting dashed lines properly.

r=100;
theta = linspace(0,2*pi,100);
[x,y] = pol2cart(theta,r*ones(1,100));
[x1,y1] = pol2cart(theta,0.9*r*ones(1,100));

rc = 0.1;
h = 0.3;
m = h/rc;
[R,A] = meshgrid(-linspace(0,rc,11),linspace(0,2*pi,50));
X3 = R .* cos(A)*r;
Y3 = R .* sin(A)*r;
Z3 = -(m*R+h)*r;


hold on
plot(x,y)
plot(x1,y1,'-.')

%plots are with anti-aliasing

s = surf(X3,Y3,Z3)


s.FaceLighting = 'gouraud';
s.AmbientStrength = 0.6;
s.DiffuseStrength = 0.8;
s.SpecularStrength = 0.9;
s.SpecularExponent = 25;
s.BackFaceLighting = 'reverselit';
s.FaceColor=[0.25 0.25 0.25];

set(s,'FaceAlpha',0.3);
set(s,'EdgeAlpha',0);

view(2)
%anti-aliasing is gone...
Luis Mendo
  • 110,752
  • 13
  • 76
  • 147
kb_
  • 131
  • 8
  • 1
    Post your code directly in the question. If it's long, post a [minimal, complete example](http://stackoverflow.com/help/mcve) – Luis Mendo Apr 05 '15 at 15:53
  • 1
    I can reproduce the problem in R2014b in Windows 7 64 bits. Anti-aliasing is lost with the `set(s,'FaceAlpha',0.3);` line – Luis Mendo Apr 05 '15 at 18:59
  • Maybe I misunderstand, but is this about exporting to pdf? Then it is possible this is not a Matlab but a pdf problem. See my question here: http://superuser.com/questions/677165/why-does-transparency-disable-subpixel-rendering-in-adobe-reader @LuisMendo – A. Donda Apr 06 '15 at 14:28
  • @A.Donda Actually, I see the antialiasing is lost when `set(s,'FaceAlpha',0.3);` is executed, even in the figure window (without exporting) – Luis Mendo Apr 06 '15 at 15:59
  • @LuisMendo, strange. Unless screen display in R2014b is somehow based on a pdf renderer. :-) I'm still stuck on 2013a... – A. Donda Apr 06 '15 at 16:33
  • @A.Donda But does R2013a have HG2? – Luis Mendo Apr 06 '15 at 16:35
  • @LuisMendo, no. Which is why I couldn't test this myself, I was just guessing a relation to my own previous issue with pdfs. – A. Donda Apr 06 '15 at 16:45
  • @A.Donda I see. Anyway, it's weird that the antialiasing goes away with that line. Maybe Matlab turns it off automatically in certain cases – Luis Mendo Apr 06 '15 at 17:13
  • HG2 is available in versions before R2014b by passing -hgVersion 2 on startup (in the shortcut for example). http://undocumentedmatlab.com/blog/matlab-hg2 – kb_ Apr 06 '15 at 19:26

0 Answers0