How to change the x axis labels of a plot so that they only show integer values
78 ビュー (過去 30 日間)
古いコメントを表示

Thanks!
3 件のコメント
回答 (2 件)
Walter Roberson
2019 年 11 月 15 日
ax = gca;
ax.Xticks = unique( round(ax.XTicks) );
2 件のコメント
Walter Roberson
2020 年 3 月 12 日
編集済み: Walter Roberson
2020 年 3 月 12 日
ax is a variable assigned the result of gca . gca is a function that returns a handle to the current axes. So ax will be assigned a handle to the current axes.
ax = gca;
ax.XTick = unique( round(ax.XTick) );
SHC
2020 年 3 月 12 日
curtick = get(gca, 'xTick');
xticks(unique(round(curtick)));
2 件のコメント
Walter Roberson
2020 年 3 月 12 日
Note: this requires R2016b or later. For earlier releases, especially before R2015b, it would look like,
curtick = get(gca, 'XTick');
set(gca, 'XTick', unique(round(curtick)))
参考
カテゴリ
Help Center および File Exchange で Labels and Annotations についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!