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

7 vues (au cours des 30 derniers jours)
Soyoung
Soyoung le 1 Déc 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.

Réponses (1)

Fangjun Jiang
Fangjun Jiang le 1 Déc 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 commentaires
Walter Roberson
Walter Roberson le 1 Déc 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 le 1 Déc 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.

Connectez-vous pour commenter.

Catégories

En savoir plus sur 2-D and 3-D Plots dans Help Center et File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!

Translated by