easy way to adjust axis labels to match x inputs
3 次查看(过去 30 天)
显示 更早的评论
Hello,
Does it need a for loop somehow?
I need the values on the x axis to show in radians, counting from 0 to 3pi, counting bu pi/20...
Graph is a simple cosine function
0 个评论
采纳的回答
Walter Roberson
2024-8-30
I doubt that is what you really want.
figure
ax = gca;
x = 0:pi/20:3*pi;
y = cos(x);
plot(ax, x, y);
xticks(ax, x);
xticklabels( ax, string(0:1/20:3) + "\pi");
I think it more likely that you only want occasional axes labels.
figure
ax = gca;
x = 0:pi/20:3*pi;
y = cos(x);
plot(ax, x, y);
xt = x(1:10:end);
xticks(ax, xt);
xticklabels(ax, string(0:1/2:3) + "\pi")
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Axis Labels 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!

