Effacer les filtres
Effacer les filtres

xticklabels showing up incomplete

80 vues (au cours des 30 derniers jours)
jrbbrt
jrbbrt le 26 Juil 2018
Commenté : jrbbrt le 2 Août 2018
Hi everybody,
So ... somehow my plot won't show me all of my xticklabels ...
What I did: I plotted 18 bins, and wanted to give each of those a specific name, which I realized with the help of defining my individual xticklabel. But when I've run my code, only the first half of them them will appear ... Even if I increase the size of my figure ... After all the bins show up in the correct amount.
x %vector with my xticklabels
set(gca,'xticklabel',x);
What could be the reason for this? And how can I change it? Might be a reason that the length of one xticklabel is too long? I am so confused ...
Best regards!
  1 commentaire
Jan
Jan le 26 Juil 2018
Please post a running code, which reproduces the problem. Which "bins" show up a wanted? How did you "plot 18 bins". Which "first half"? A screenshot might help.

Connectez-vous pour commenter.

Réponse acceptée

Adam Danz
Adam Danz le 26 Juil 2018
Modifié(e) : Adam Danz le 1 Août 2018
You're probably not setting the 'XTick' property.
Here's an example that replicates the problem you're describing.
figure
plot(rand(1,20), rand(1,20))
xlab = {'a' 'b' 'c' 'd' 'e' 'f' 'g' 'h' 'i' 'j' 'k' 'l' 'm' 'n' 'o' 'p' 'q' 'r' 's' 't' 'u' 'v' 'w' 'x' 'y' 'z'};
set(gca, 'XTickLabels', xlab)
In that figure (left) you'll only see letters a:k because the original ticks were 0 : 0.1 : 1.
Now set the ticks correctly by using 'XTick'. Here I use space them equally along the x axis but you'll use the x values where your labels should go.
set(gca, 'XTick', linspace(0,1,length(xlab)), 'XTickLabels', xlab)
Now you see all of the labels (right).

Plus de réponses (1)

Jan
Jan le 26 Juil 2018
Maybe the number of 'XTick' does not equal the number of 'XTickLabel'? This would be clear, if you post the code.
Label = {'1', '2', '3', '4', '5', '6', '7', '8', '9', '10'};
Axes1H = subplot(1,2,1);
plot(1:10);
set(Axes1H, 'XTick', 1:5, 'XTickLabel', Label);
Axes2H = subplot(1,2,2);
plot(1:10);
set(AxesH, 'XTick', 1:10, 'XTickLabel', Label);
  8 commentaires
Adam Danz
Adam Danz le 1 Août 2018
I see.
new_xtick must be a row vector. If it's a column vector, transpose it.
strsplit(num2str(new_xtick'))
jrbbrt
jrbbrt le 2 Août 2018
Adam, my hero! Thank you, that actually worked for me :)

Connectez-vous pour commenter.

Catégories

En savoir plus sur Labels and Annotations dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by