How to have different scales in the same x axis?

2 views (last 30 days)
I have a xy dataset with x values ranging form 0 to 100 million with uniform spacing and an additional data point at x = 2 billion. Therefore, whenever I try to plot the entire dataset, the plot in the range of 0 to 100 million takes a very narrow space in the entire plot.
If I only plot from 0 to 100 million range, I get a uniform spacing in the xtick labels (for example 1 million). Is there any way that I can have same spacing between 100 million to 2 billion point?

Answers (1)

Jan
Jan on 21 Jun 2022
Edited: Jan on 21 Jun 2022
Set the XTickLabels accordingly with fake XTicks:
X = [1,2,3,4,5,6, 100];
Y = rand(size(X));
axes('NextPlot', 'add', 'XTick', 1:numel(X), 'XTickLabel', X);
plot(1:numel(X), Y)

Products


Release

R2020a

Community Treasure Hunt

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

Start Hunting!