How to remove some xticklabels (but still keeping all the xticks)?
4 visualizzazioni (ultimi 30 giorni)
Mostra commenti meno recenti
How can I remove some xticklabels, but still keeping all the xticks?
Let's consider the following example:
x = 1:100;
y = exp(-0.1*x);
plot(x,y)
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/1800350/image.png)
I want to remove the xticklabels corresponding to "0", "10", "20", "30", getting the following plot:
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/1800355/image.png)
How can I do it?
I tried the following, without success:
ax = gca;
ax.XTickLabel(1:4) = '';
0 Commenti
Risposta accettata
Voss
il 29 Ott 2024
x = 1:100;
y = exp(-0.1*x);
plot(x,y)
ax = gca;
ax.XTick = 0:10:100;
ax.XTickLabels(1:4) = {''};
0 Commenti
Più risposte (1)
Steven Lord
il 29 Ott 2024
x = 1:100;
y = exp(-0.1*x);
plot(x,y)
xticks(0:10:100)
xl = xticklabels;
xl(1:2:end) = {''}; % Replace every other label
xticklabels(xl)
Vedere anche
Categorie
Scopri di più su Axis Labels in Help Center e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!