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 plot(1:5,2:6,'o-', 'LineWidth',1);
% Smoothed (anti-aliased) plot line 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
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.
Do you use have any other favorite undocumented/hidden property? If so, please share it in a comment below.