text in subplot with large font

2 ビュー (過去 30 日間)
Kcire L
Kcire L 2023 年 2 月 14 日
移動済み: Voss 2023 年 2 月 14 日
Hello,
I'm trying to add text in a subplot instead of a chart that displays respiratory rate. I am using the code below, however, I'm not sure how to add my calculated RR after the text and I would like to make the font size much larger. Any help with this would be greatly appreciated.
Thanks,
subplot(3,3, [6 6]);
text(0.5, 0.5, 'Respiratory Rate');
axis off

採用された回答

Voss
Voss 2023 年 2 月 14 日
RR = 99.99;
font_size = 12;
subplot(3,3,6);
text(0.5, 0.5, sprintf('Respiratory Rate: %.2f',RR), 'FontSize', font_size);
axis off
xlim([5 20]) % this is so you can see the entire text
  2 件のコメント
Kcire L
Kcire L 2023 年 2 月 14 日
移動済み: Voss 2023 年 2 月 14 日
Thanks for that answer. One thing, however, I am updating this supblot periodically and need to clear the respiratory rate for each update. Right now the new text and RR just gets added on to the previous like this.
Respiratory Rate: 5.55 Respiratory Rate: 5.85 Respiratory Rate 6.79
I'd like to just keep a single "Respiratory Rate" text and update the number
Voss
Voss 2023 年 2 月 14 日
移動済み: Voss 2023 年 2 月 14 日
That looks like RR is a vector, because sprintf with a vector will do that:
RR = [5.55 5.85 6.79];
sprintf('Respiratory Rate: %.2f',RR)
ans = 'Respiratory Rate: 5.55Respiratory Rate: 5.85Respiratory Rate: 6.79'
What you can do is create the text once, and then use one element of RR to update its string for each update:
% suppose you have these RR values:
RR = [5.55 5.85 6.79];
% create the text:
font_size = 12;
t = text(0.5, 0.5, '', 'FontSize', font_size);
% now loop over the RR values and update the text String:
for ii = 1:numel(RR)
set(t,'String',sprintf('Respiratory Rate: %.2f',RR(ii)));
end

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

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeLabels and Annotations についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by