MATLAB Answers

Multi-line x-tick label MATLAB bar graph

96 views (last 30 days)
AM
AM on 30 Jul 2014
Edited: Matt J on 26 Feb 2019
How can I get my bar graphs 'A', 'B', 'C' to be multi-line strings? I would like to have two lines for each 'A', 'B', or 'C', but I don't know how to make newline in str, within set()
This is the working code I have so far:
x = [1 2 3];
str = {'A'; 'B'; 'C'};
bar(x)
set(gca, 'XTickLabel',str, 'XTick',1:numel(str))
And the output:
Thanks.

  0 Comments

Sign in to comment.

Accepted Answer

dpb
dpb on 30 Jul 2014
Tick labels don't have TeX interpreter so no can do w/ them. Use text instead...altho you might search File Exchange for any enhanced tick-writing toolsets that may have already done for you.

  0 Comments

Sign in to comment.

More Answers (0)

Sign in to answer this question.