Xticklabels remaining fixed when replotting with different x values

4 ビュー (過去 30 日間)
Jason
Jason 2015 年 11 月 6 日
編集済み: Thorsten 2015 年 11 月 6 日
I have a plot that I manually scale. I also want to adjust the fontsize of the ticklabels. so my code is:
xlim([0 xdata(end)])
a = get(gca,'XTickLabel');
set(gca,'XTickLabel',a,'FontName','Helvetica','fontsize',6);
But, say my first plot has 1600 points, all is well. But when I perform the same plot with say 400 points of data, the graph displays correctly but the ticklabels still read upto 1600.
  1 件のコメント
Jason
Jason 2015 年 11 月 6 日
It seems if I replace the following it works, not sure why?
% a = get(gca,'XTickLabel');
% set(gca,'XTickLabel',a,'FontName','Helvetica','fontsize',6);
set(gca,'FontSize',6,'FontName','Helvetica')

サインインしてコメントする。

採用された回答

Thorsten
Thorsten 2015 年 11 月 6 日
編集済み: Thorsten 2015 年 11 月 6 日
If you just want to change the size of the font, use
set(gca, 'FontSize', 6);
If you want to set different XTickLabels, use
set(gca, 'XTickLabel', whatever_labels_you_want)
There is no reason to first get the property of the current axis and next set it to its value, like in
a = get(gca,'XTickLabel');
set(gca,'XTickLabel',a)
You just set the values to what they already are.
Presumably you have used a value of "a" from a previous run with the labels running up to 1600 and then you used this "a" for your smaller plot with just 400 points, and so you got the labels wrong.

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeLabels and Styling についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by