How to use string as data for plotting in Matlab?

后端 未结 4 1073
轮回少年
轮回少年 2020-12-09 04:42

I want to use a words like, let\'s say, \'A\', \'B\' and \'C\' on X-axis to show their corresponding properties on Y-axis. How can I write these strings on X-axis instead of

4条回答
  •  南方客
    南方客 (楼主)
    2020-12-09 05:29

    Use 'XTick' and 'XTickLabel' properties of the axes handle.
    Here's a simple example:

    x = 1:5;
    y = rand(size(x));
    plot(x, y, 'b')
    set(gca, 'XTick',1:5, 'XTickLabel',{'A' 'B' 'C' 'D' 'E'})
    

    alt text

提交回复
热议问题