MATLAB: How to format the axis of the plot plot how can i display the whole number in the x-axis and not 18*10^5? Best Answer %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')endset(gca, 'XTickLabel', XTickLabel) Related SolutionsMATLAB: Deletting X and Y axes ticks set(gca,'xtick',[]) set(gca,'ytick',[]) MATLAB: Change scaling of x-axis Try this:x = 0:260; % Create Datay = rand(size(x)); % Create Datafigure(1)plot(x, y)xt = get(gca, 'XTick'); % 'XTick' Valuesset(gca, 'XTick', xt, 'XTickLabel', xt/140) % Relabel 'XTick' With 'XTickLabel' ValuesThe set call relabels the 'XTick' values with the same values divided by 140. Related QuestionImproving readability of Matlab graphHow to remove the ‘x10^5’ indicator next to the axes in MATLAB 7.14 (R2012a)Spectrogram x axis logarithmic
Best Answer