Clear Filters
Clear Filters

How to set even spacing between preset tick marks

36 views (last 30 days)
Hello,
I am trying to evenly space tick marks that I have set using set(gca,'XTick',[]) in order to better capture regions of high change in my plot:
LineColor1 = 'b';
el1=readmatrix("element152322_bimodal.csv");
plot(el1(:,1),el1(:,2),LineColor1,'LineWidth',LineWidth)
xlim([60 100])
set(gca,'XTick',[60.7 60.9 91.1 91.3])
I have not been able to find a way to do this. Is there any way to do it withour modifying my data, or an easy way to modify it for this purpose?
  1 Comment
dpb
dpb on 13 May 2022
Ticks don't change the range, they simply are shown on the axis at the positions given; to expand a region you would have to set xlim or use the zoom feature.
Unfortunately, MATLAB graphics axis object does not support a broken/split axis automagically to be able to blow up two disparate areas such as you have simultaneously; it maintains a continuous x axis between the limits and draws the data at the actual x values.
It would take drawing the two sections on separate axes to show both simultaneously.
There may be some submissions on the File Exchange that could facilitate this; it's another one of those obvious enhancements that just hasn't ever made it...

Sign in to comment.

Accepted Answer

Jan
Jan on 13 May 2022
What do you exactly want as output?
Beside the possibility to do this in Matlab, think twice if the person can understand the output on first view. An irregulare scaling with some magnified areas is a perfect way to present confusing data.
One way to show the areas of interest is to show the areas of interest:
LineColor1 = 'b';
el1=readmatrix("element152322_bimodal.csv");
t = el1(:, 1);
y = el1(:, 2);
m1 = (t >= 60.7) & (t <= 60.9);
ax1 = subplot(1,2,1);
plot(t(m1), y(m1));
xlim([60.7, 60.9]);
m1 = (t >= 91.1) & (t <= 91.3);
ax2 = subplot(1,2,2);
plot(t(m1), y(m1));
xlim([91.1, 91.3]);
Another option is to use a logarithmic scaling for the y axis.

More Answers (0)

Categories

Find more on Polar Plots in Help Center and File Exchange

Products


Release

R2021b

Community Treasure Hunt

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

Start Hunting!