I have a vector x = 1:20 and another vector y.
When I plot x versus y, the x-axis has labels in increments of 2. That is, x-axis shows, 0,2,4,6,8,...,20. But I want my x-axis to show 0,1,2,3,4,...,20.
How do I do this?
I recommend looking at this: http://www.mathworks.com/help/matlab/creating_plots/change-tick-marks-and-tick-labels-of-graph-1.html
If you have MATLAB version 2014b or later:
ax = gca;
ax.xTick = 0:20;
A more general solution that works with any version of MATLAB:
ax = gca;
set(ax, 'XTick', 0:20);
要修改绘图上的x和y网格,可以使用Matlab文档中此处所示的XTick
和YTick
。
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.