Custom x-axis values in a matlab plot

前端 未结 3 1573
没有蜡笔的小新
没有蜡笔的小新 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 17:06

    Try using

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

    Please note that due to the very different values/magnitudes to use un x-axis you can get some x-labels very close (and unreadable)

提交回复
热议问题