Matlab R2014b中正式发布的"LineSmoothing"特征数年前的版本中已经存在


可以看到这里有过讨论:

http://stackoverflow.com/questions/17551346/does-matlab-2013a-support-retina-display



2 down vote

I don't know about retina displays (I think that's a Mac OS thing, I'm on Windows), but MATLAB plots are not anti-aliased.

At least thats the case in the current version, it seems MATLAB is working on updating its graphics system to be AA by default.

 

There is an undocumented way to get smooth lines you can also play with.

Finally there are other tricks to get nice smooth plots (by drawing at a higher resolution, then subsampling and saving the image). Take a look at this FEX submission: myaa

这个myaa不得不提:

http://www.mathworks.com/matlabcentral/fileexchange/20979-myaa-my-anti-alias-for-matlab

http://www.mathworks.com/matlabcentral/fileexchange/screenshots/2415/original.jpg


代码和对比的应用:

点击打开链接


Plot LineSmoothing property
Wednesday, March 17th, 2010
 updates on Undocumented Matlab topics.
I have already written about several undocumented hidden properties in the past. Today, I would like to introduce one of my favorites: the plot-line’s LineSmoothing property. Compare the following two outputs:

% Standard (non-smoothed) plot-line
subplot(121);plot(1:5,2:6,'o-', 'LineWidth',1);


% Smoothed (anti-aliased) plot line
subplot(122);plot(1:5,2:6,'o-', 'LineWidth',1, 'LineSmoothing','on');




Line smoothing (aka anti-aliasing) works by inserting semi-transparent pixels at the edges of the actual plot line, thereby giving an optical illusion of a smooth line without pixelization effects. In Matlab, antialiasing is done automatically for fonts, but unfortunately not for plot lines that have non-default line-widths.


Line-smoothing has been around for a long time. It was even mentioned in a user comment on the official MathWorks Pick-of-the-Week article that introduced the excellent Myaa utility (Myaa uses applicative Matlab code to create anti-aliased plot effects).


However, to this day ( R2010a), the LineSmoothing property remains hidden, undocumented and not officially supported.


Perhaps the reason for this is the following bug: text objects that cross a smoothed line are obscured by it. Depending on the text size and the line width, the text might be completely hidden, although its handle indicates that it is visible and despite it being created after the plot line!

plot(1:5,2:6,'.-', 'LineWidth',5, 'LineSmoothing','on');
text(2.2,3.5, 'abcd','Color','r');



Note that this does not happen for standard (non-smoothed) lines:

plot(1:5,2:6,'.-', 'LineWidth',5);
text(2.2,3.5, 'abcd','Color','r');



Luckily, there’s a very simple workaround for this, that allows both line-smoothing and non-obstruction: simply set the text‘s z-position to a higher value than the plot line’s. In our example, we used a simple 2D plot line (i.e., z-position = 0), so let’s set z-position=1 for our text label:


plot(1:5,2:6,'.-', 'LineWidth',5, 'LineSmoothing','on');
text(2.2,3.5,1, 'abcd','Color','r');



MathWorks have developed a special workaround for the LineWidth problem in OpenGL, using


opengl('OpenGLLineSmoothingBug',1)


Unfortunately, as far as I could tell it has no visible effect in this particular case (perhaps I forgot to do something?).


One final note: the LineSmoothing property also exists for line, patch, surf, mesh and other similar objects.

你可能感兴趣的:(学习学习)