How can I disable font smoothing within a legend?

5 ビュー (過去 30 日間)
HoBe
HoBe 2015 年 4 月 21 日
編集済み: Brian C Coe 2019 年 6 月 18 日
I want to globally disable font smoothing for all text entries within figures, since smoothed text looks very poor on my display.
I tried:
set(groot, 'DefaultTextFontSmoothing', 'off');
set(groot, 'DefaultAxesFontSmoothing', 'off');
which seems to work for xlabel(), title(), etc. but not for the text within legends.
I am using Matlab R2015a.

採用された回答

Brian C Coe
Brian C Coe 2019 年 5 月 30 日
編集済み: Brian C Coe 2019 年 6 月 18 日
function [leg,labelhandles,outH,outM] = legend2(varargin)
% function [leg,labelhandles,outH,outM] = legend2(varargin)
% quite possibly the stupidest code i ever had to hack-up to get around a matlab stupidity.
% call 'legend2' instead of 'legend' to remove the noisy font smoothing.
% still can't figure out how to remove the graphicssmoothing, however.
% 2019may31 ~bcoe
if isempty(varargin)
help(mfilename)
return
end
[leg,labelhandles,outH,outM] = legend(varargin{:});
for ii=1:length(leg.ItemText)
leg.ItemText(ii).FontSmoothing='off';
% leg.ItemTokens(ii).graphicssmoothing='off'; %still trying to kill linesmoothing
end
call 'legend2' instead of 'legend'... (-sigh-)

その他の回答 (1 件)

Cindy Solomon
Cindy Solomon 2015 年 4 月 22 日
Hi HoBe,
In order to turn off the font smoothing of a legend, you can set the FontSmoothing property of a text object that is a child of the legend. For example:
plot(1:10)
[h,objs] = legend('one')
objs(1).FontSmoothing='off'
Since the legend is no longer a child of the axis, changing the FontSmoothing property of the axis does not have any impact on the legend. Hope this helps!
  1 件のコメント
HoBe
HoBe 2015 年 4 月 23 日
Hi Cindy,
thanks for your answer. This solution works for me as a workaround. However, is there a way to turn off font smoothing of legends on a global level? I would expect that
set(groot, 'DefaultTextFontSmoothing', 'off');
should do the job, but it does not.

サインインしてコメントする。

カテゴリ

Help Center および File ExchangeLegend についてさらに検索

製品

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by