How do I place a two-lined title, x-label, y-label, or z-label on my plot?

조회 수: 765 (최근 30일)
I would like to create a multi-lined title, x-label, y-label or z-label. I would like to know if there are any functions in MATLAB that allow me to create a title that uses multiple lines.

채택된 답변

MathWorks Support Team
MathWorks Support Team 2017년 6월 12일
편집: MathWorks Support Team 2017년 6월 12일
You can create multi-line text using a cell array. For example, this code creates a title and an axis label with two lines.
plot(1:10)
title({'First line';'Second line'})
xlabel({'First line';'Second line'})
For more information about creating multiline text, see

추가 답변 (1개)

Karan Gill
Karan Gill 2016년 10월 31일
Replace spaces with "\newline".
labels = {'line1 line2','line1 line2','line1 line2'};
labels = cellfun(@(x) strrep(x,' ','\newline'), labels,'UniformOutput',false);
a = gca;
a.XTickLabel = labels;
Karan | Symbolic Math documentation

카테고리

Help CenterFile Exchange에서 Labels and Annotations에 대해 자세히 알아보기

제품

Community Treasure Hunt

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

Start Hunting!

Translated by