# Change scale of x-axis on plot

76 vues (au cours des 30 derniers jours)
Megan Thompson le 9 Nov 2021
Hi, my code plots 3 lines onto one plot
The x-axis scale is very big, 0 to 40,000, while the y axis is very small (between +/- 0.06)
When I do my plot the x-axis shows the scale 0 to 4, (x 10^4). How do I change it so that it simply says 0 to 40,000 instead?
Thank you!
##### 0 commentairesAfficher -2 commentaires plus anciensMasquer -2 commentaires plus anciens

Connectez-vous pour commenter.

### Réponses (3)

Joseph Cheng le 9 Nov 2021
there are different methods posted there that should work for you
##### 0 commentairesAfficher -2 commentaires plus anciensMasquer -2 commentaires plus anciens

Connectez-vous pour commenter.

dpb le 9 Nov 2021
hAx=gca;
hAx.XAxis.TickLabelFormat='%d';
hAx.XAxis.Exponent=0;
##### 0 commentairesAfficher -2 commentaires plus anciensMasquer -2 commentaires plus anciens

Connectez-vous pour commenter.

Mathieu NOE le 9 Nov 2021
hello Megan
you have to create a specific XTick / XTickLabel to represent the number the way you prefer
here an example with 5 values of the x data vector used to create the new XTick / XTickLabel
x = (0:40e3);
y = randn(size(x))*0.02;
N = 5;
xt = linspace(min(x),max(x),N);
XtLabels = num2cell(xt);
plot(x,y);
set(gca,"XTick",xt,"XTickLabel",XtLabels);
##### 0 commentairesAfficher -2 commentaires plus anciensMasquer -2 commentaires plus anciens

Connectez-vous pour commenter.

### Catégories

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

R2020b

### Community Treasure Hunt

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

Start Hunting!

Translated by