how to mark the first and the last points on the plot

7 Ansichten (letzte 30 Tage)
Soyoung
Soyoung am 1 Dez. 2011
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.

Antworten (1)

Fangjun Jiang
Fangjun Jiang am 1 Dez. 2011
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 Kommentare
Walter Roberson
Walter Roberson am 1 Dez. 2011
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
Fangjun Jiang am 1 Dez. 2011
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.

Melden Sie sich an, um zu kommentieren.

Kategorien

Mehr zu 2-D and 3-D Plots finden Sie in Help Center und File Exchange

Tags

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by