xticklabels showing up incomplete
古いコメントを表示
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 件のコメント
Jan
2018 年 7 月 26 日
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.
採用された回答
その他の回答 (1 件)
Jan
2018 年 7 月 26 日
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 件のコメント
jrbbrt
2018 年 8 月 1 日
Adam Danz
2018 年 8 月 1 日
num2str() creates 1 string of all your numbers (eg: '2 4 6 8 10'). You need to split them using
strsplit(num2str());
So your code will be
set(gca, 'XTick', new_xtick, 'XTickLabel', strsplit(num2str(new_xtick)))
Adam Danz
2018 年 8 月 1 日
What are the values of new_xtick?
jrbbrt
2018 年 8 月 1 日
Adam Danz
2018 年 8 月 1 日
I see.
new_xtick must be a row vector. If it's a column vector, transpose it.
strsplit(num2str(new_xtick'))
jrbbrt
2018 年 8 月 2 日
カテゴリ
ヘルプ センター および File Exchange で Data Distribution Plots についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!
