フィルターのクリア

how to format the axis of the plot?

2 ビュー (過去 30 日間)
ocsse
ocsse 2018 年 5 月 3 日
回答済み: OCDER 2018 年 5 月 3 日
how can i display the whole number in the x-axis and not 18*10^5?

採用された回答

OCDER
OCDER 2018 年 5 月 3 日
%OPTION 1: Overwrite the XTickLabel property of the axes. (Simpler code but messy plot)
plot([1:10]*10^6, 1:10)
XTick = num2cell(get(gca, 'XTick'));
XTickLabel = cellfun(@(x) sprintf('%0.0f', x), XTick, 'unif', false);
set(gca, 'XTickLabel', XTickLabel, 'XTickLabelRotation', 90)
%OPTION 2: Determine what power was used, then adjust the x-axis name and XTickLabel. (Cleaner plot)
plot([1:10]*10^6, 1:10)
XTick = get(gca, 'XTick');
XTickLabel = get(gca, 'XTickLabel');
XTickLabelNum = str2double(XTickLabel{end});
Power = log10(XTick(end)/XTickLabelNum);
if Power ~= 0
xlabel(sprintf('X TEXT (x 10^{%d})', Power))
else
xlabel('X TEXT')
end
set(gca, 'XTickLabel', XTickLabel)

その他の回答 (1 件)

Yuvaraj Venkataswamy
Yuvaraj Venkataswamy 2018 年 5 月 3 日

カテゴリ

Help Center および File ExchangeAnnotations についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by