add text to value of a plot, part 2
2 views (last 30 days)
Show older comments
I have a plot with x axis takes the value January 1, January 2, .... and y axis takes the temperature of that day. In the x axis, I want to have these days and add a text "day" to these values so that they will be "Day 1 (January 1)","Day 2 (January 2)", "Day 3 (January 3)",... I did not find a relevant post on the Internet.
0 Comments
Accepted Answer
Star Strider
on 26 May 2020
That needs a different approach.
Try this:
x = 1:10
y = rand(1,10);
figure
plot(x, y)
xt = get(gca, 'XTick');
xtklbl = sprintfc('Day %d (January %d)', [xt; xt]');
set(gca, 'Xtick',xt, 'XTickLabel',xtklbl, 'XTickLabelRotation',30)
9 Comments
Star Strider
on 26 May 2020
As always, my pleasure!
I quite definitely agree that it is not an easy problem!
More Answers (0)
See Also
Categories
Find more on Annotations in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!