Custom x-axis values in a matlab plot

前端 未结 3 1639
没有蜡笔的小新
没有蜡笔的小新 2021-01-17 16:38

Currently when I plot a 9 by 6 array, the x-axis of the figure is just 1, 2, 3 up to 9. The Y-axis shows the correct values.

Instead of 1 to 9 I would like the x-axi

3条回答
  •  醉酒成梦
    2021-01-17 16:53

    If you want to keep distances between x-values (e.g. 1:9) and only change the labels (not the distances between x-values), try this:

    y = rand(9,6);
    labels = [100 200 400 1000 2000 5000 10000 20000 50000];
    plot(y);
    set(gca, 'XTick', 1:length(labels)); % Change x-axis ticks
    set(gca, 'XTickLabel', labels); % Change x-axis ticks labels.
    

提交回复
热议问题