How to set even spacing between preset tick marks
조회 수: 36 (최근 30일)
이전 댓글 표시
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])
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/996875/image.png)
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
dpb
2022년 5월 13일
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...
채택된 답변
Jan
2022년 5월 13일
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.
댓글 수: 0
추가 답변 (0개)
참고 항목
카테고리
Help Center 및 File Exchange에서 Polar Plots에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!