how to mark the first and the last points on the plot
7 次查看(过去 30 天)
显示 更早的评论
I could not have the value at the end point of the plot when I used the following code as an example:
plot(1:1:100,data(1:1:100));
set(gca,'XTick',1:10:100);
set(gca,'XTickLabel',0:1:9);
but I could not have first and last point value properly. How can I set them at the first and the last position well?
If you know anyone on my question, please let me know. Thank you.
0 个评论
回答(1 个)
Fangjun Jiang
2011-12-1
I don't fully understand your question or problem. Is this what you want?
plot(1:1:100,data(1:1:100));
set(gca,'XTick',0:10:100);
set(gca,'XTickLabel',0:1:10);
Update
plot(1:100,1:100);
set(gca,'XTick',1:10:101);
set(gca,'XTickLabel',0:1:10);
axis([0 110 0 110])
3 个评论
Walter Roberson
2011-12-1
You do not get the 10 in your original code because your original code stops labeling at 9.
When I try Fangjun's code, I do get the 10 appearing.
To get the plot box to touch the outside of the plot, command
axis tight
Fangjun Jiang
2011-12-1
To have 11 Xticks starting from 1, you will have to use 1:10:101, not 1:10:100.
You data range is from 1 to 100. The axis is set automatically so xlim is set at [1 100]. To show the Xtick of 101, you will need to use xlim() or axis() to set it properly. See update.
另请参阅
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!