I can't seem to change figure font name

4 ビュー (過去 30 日間)
Chris Oxford
Chris Oxford 2017 年 12 月 1 日
コメント済み: Greg 2018 年 7 月 18 日
I run the following simple code and get Helvetica as a font.
fntsz=10;
font='LibreBaskerville-Regular';
axes1=axes('FontName',font,'FontSize',fntsz);
plt1=plot(TDMAINVTAO{1}.sd(:,1),TDMAINVTAO{1}.sd(:,2),'b');
set(plt1,'parent',axes1)
xlabel('Diameter (nm)')
ylabel('dN/dD{p} (#/cc/nm)')
I have tried the following as well...
set(findall(fig1,'-property','FontName'),'FontName',font)
When I try to change the axes font using the axes property editor, LibreBaskerville-Regular is not available.
However, when I run listfonts, LibreBaskerville-Regular is in the list.
I am currently running R2012a.
Chris

採用された回答

Jan
Jan 2017 年 12 月 2 日
Set the default values for the fonts, when you create the figure:
font = 'LibreBaskerville-Regular';
figure('DefaultTextFontName', font, 'DefaultAxesFontName', font);
axes;
text(0.5, 0.5, 'Hello!');
Now the text and the tick labels use the wanted font.
  5 件のコメント
Jan
Jan 2017 年 12 月 8 日
Which "editor" do you mean?
Chris Oxford
Chris Oxford 2017 年 12 月 8 日
If I have the figure open, I click edit in the menu bar, and select axis properties. Then select the font tab. The font name will be listed as Helvetica. If I query through get(), it will return LibreBaskerville-Regular.

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

その他の回答 (1 件)

Greg
Greg 2017 年 12 月 2 日
It looks like the 'NextPlot' (normally manipulated with hold on and hold off) behavior includes things like FontName for the axes. Try:
font='LibreBaskerville-Regular';
axes1=axes();
plt1=plot(axes1,TDMAINVTAO{1}.sd(:,1),TDMAINVTAO{1}.sd(:,2),'b');
set(axes1,'FontName',font,'FontSize',fntsz);
  2 件のコメント
fluid
fluid 2018 年 7 月 18 日
Yeah, this is it
Greg
Greg 2018 年 7 月 18 日
You can change your accepted answer if this one is more accurate or complete.

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

カテゴリ

Help Center および File ExchangeCreating, Deleting, and Querying Graphics Objects についてさらに検索

製品

Community Treasure Hunt

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

Start Hunting!

Translated by