Main Content

使用图形平滑处理

此示例说明如何在您的绘图中使用图形和字体平滑处理。

什么是图形平滑处理?

图形平滑处理可改进绘图中图形的外观。平滑处理会消除使用像素或点表示连续对象时产生的锯齿状边缘。用于图形平滑处理的技术包括多采样处理和抗锯齿。

图窗中的图形平滑处理

通过使用 GraphicsSmoothing 属性在图窗中控制图形平滑处理。默认情况下,GraphicsSmoothing 属性设置为 'on'。

f = figure;
surf(peaks)

Figure contains an axes object. The axes object contains an object of type surface.

您可以通过将 GraphicsSmoothing 属性设置为 'off' 以关闭图形平滑处理。

f.GraphicsSmoothing = 'off';

Figure contains an axes object. The axes object contains an object of type surface.

文本和坐标区对象的字体平滑处理

文本和坐标区对象的 FontSmoothing 属性控制文本的渲染方式。当 FontSmoothing 属性设置为 'on' 时,文本将以平滑的边缘绘制。默认情况下,字体平滑处理为 'on'。

t = text(14,27,-8.5, 'Minimum of Peaks');

Figure contains an axes object. The axes object contains 2 objects of type surface, text.

t.FontSmoothing = 'off';

Figure contains an axes object. The axes object contains 2 objects of type surface, text.

为何关闭图形平滑处理?

如果不做图形平滑处理,水平和垂直线条将显示得更加锐利。当图形平滑处理关闭时,某些图表类型可能显示效果更好。同样,关闭字体平滑处理后,使用小字体的文本看起来会更加清晰。

pcolor(rand(6))

Figure contains an axes object. The axes object contains an object of type surface.

ax = gca;                       % get current axes          
ax.FontSmoothing = 'off';       % turn off axes font smoothing

Figure contains an axes object. The axes object contains an object of type surface.

f.GraphicsSmoothing = 'off';    % turn off figure graphics smoothing