set(gca,'fontsize',[]) reporting error

26 ビュー (過去 30 日間)
Xingda Chen
Xingda Chen 2021 年 7 月 17 日
コメント済み: Image Analyst 2021 年 7 月 18 日
Hi all, I bumped into a simple problem but I do not know what is going on.
I was trying to make a plot and seting up the font size (like I had done many times before). But this time matlab returns an error that I do not really understand, here is my code:
load('sim5.mat')
maxs=smooth(maxs);
figure
hold on
plot(maxs,ko,'LineWidth',5)
xlabel('success probability')
ylabel('number of tags')
set(gca,'fontsize',18)
box off
and at
set(gca,'fontsize',18)
maltab reports this error:
Unrecognized property 'fontsize' for class 'matlab.ui.Figure'.
I am not sure what is going on here?
  2 件のコメント
Walter Roberson
Walter Roberson 2021 年 7 月 17 日
What output do you get if you ask to display
gca
It sounds as if you are getting a figure instead of an axes, which is strange.
What shows up for
which -all gca
Xingda Chen
Xingda Chen 2021 年 7 月 18 日
ok i ran today and all is good. I am going to close this since the problem exists no more although I still don't know what went wrong.

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

採用された回答

Image Analyst
Image Analyst 2021 年 7 月 18 日
Just set font size explicitly in xlabel():
load('sim5.mat')
maxs=smooth(maxs);
figure
hold on
plot(maxs, ko, '-', 'LineWidth', 5);
grid on;
fontSize = 18;
title('ko vs. maxs', 'FontSize', fontSize)
xlabel('success probability', 'FontSize', fontSize)
ylabel('number of tags', 'FontSize', fontSize)
box off

その他の回答 (1 件)

Walter Roberson
Walter Roberson 2021 年 7 月 18 日
maybe you had happened to do
gca = (a figure)
For historical reasons, if you had happened to do something like
gca = 1
set(gca, 'fontsize', 18)
then provided that a figure existed with that figure number, you would get the error message that you received.
  1 件のコメント
Image Analyst
Image Analyst 2021 年 7 月 18 日
For what it's worth, this works for me in r2021a:
figure
hold on
plot(1:10, 'LineWidth',5)
xlabel('success probability')
ylabel('number of tags')
set(gca,'fontsize',18) % Works - no problem.
gca.FontSize = 18 % More modern OOP way -- also works.

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

カテゴリ

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

タグ

製品


リリース

R2021a

Community Treasure Hunt

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

Start Hunting!

Translated by