Figure 内の凡例(legend)を複数の行で表示できますか?
55 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
MathWorks Support Team
am 24 Feb. 2022
Beantwortet: MathWorks Support Team
am 24 Feb. 2022
Figure でグラフを作成しています。
一つのラインに対する凡例内の文字列が長いので、複数の行に分割して表示できるか、教えてください。
Akzeptierte Antwort
MathWorks Support Team
am 24 Feb. 2022
凡例(legend) を複数行で表示するためには、newline 関数もしくは ASCII コードの 10 (char(10) を挿入して、改行コードを含めます。
plot(sin(1:10),'b')
hold on
plot(cos(1:10),'r')
legend({['blue' char(10) 'line'],'red line'})
R2016b 以降の string 配列を用いる場合は、以下のように記述可能です。
>> legend({ "blue" + newline + "line", 'red line'})
もしくは
>> legend({ strcat("blue", string(newline), "line"), 'red line' })
また、Figure 内の凡例をダブルクリックすることで、テキストを直接編集し、改行を挿入することも可能です。
0 Kommentare
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu Legend finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!