add text to value of a plot, part 2
2 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
alpedhuez
el 26 de Mayo de 2020
Comentada: alpedhuez
el 26 de Mayo de 2020
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 comentarios
Respuesta aceptada
Star Strider
el 26 de Mayo de 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 comentarios
Star Strider
el 26 de Mayo de 2020
As always, my pleasure!
I quite definitely agree that it is not an easy problem!
Más respuestas (0)
Ver también
Categorías
Más información sobre Annotations en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!