# break x axis on matlab plot

조회 수: 13 (최근 30일)
Ioannis Vourvachakis 2022년 7월 3일
편집: Walter Roberson 2022년 7월 5일
Hello!
I want to use this ''break x axis'' function (or any other similar function) https://www.mathworks.com/matlabcentral/fileexchange/68878-break-and-flop-along-axis?s_tid=srchtitle , on my following diagramm.
I want to break the x axis two times. The first time I want to hide the range of values between -40 and -10. The second time I want to hide the range between 10 and 40. For accuracy, my purpose is to focus on the range between -10 and 10.
The following script is to make this plot:
figure
hold on
plot([CBBminmax1(:,1)';CBBminmax1(:,2)'],[1:13; 1:13],'color','g', 'LineWidth',26)
plot([CBBminmaxpost(:,1)';CBBminmaxpost(:,2)'],[1:13; 1:13],'color','r', 'LineWidth',16)
I also attached a mat file for the variables CBBminmax1 and CBBminmaxpost.
I find it very difficult to use any ''break x axis'' function from here https://www.mathworks.com/matlabcentral/fileexchange?q=break+axis , for what I want to do on my diagramm.
If anyone can help me and show me how I can do it, I wound appreciate it very much.
Thank you
##### 댓글 수: 3이전 댓글 1개 표시이전 댓글 1개 숨기기
Ioannis Vourvachakis 2022년 7월 3일
Thank you Simon, how exactly did you use XTickLabel to make this plot?
You mean that the values on the plot still correspond to x axis -[100,100]?
Simon Chan 2022년 7월 5일
You may subtract the magnitude of those values which are greater than 40 and less than -40 by the length of the gap. That means the actual values are deducted and hence the XTick corresponds to [-80 80] only for example, while manually edit the XTickLabel to [-100 100]. Hence I mentioned that the original values are actually incorrect. Of course, this is not the optimal solution and let's see whether someone will give you a better answer.

댓글을 달려면 로그인하십시오.

### 답변 (1개)

Keshav 2022년 7월 3일
Hi, Based on my understanding you want to focus only on the range between -10 and 10 on x axis. you can use the xlim function inorder to set the limit on x axis.
figure
hold on
plot([CBBminmax1(:,1)';CBBminmax1(:,2)'],[1:13; 1:13],'color','g', 'LineWidth',26)
plot([CBBminmaxpost(:,1)';CBBminmaxpost(:,2)'],[1:13; 1:13],'color','r', 'LineWidth',16)
xlim([-10 10])
##### 댓글 수: 1이전 댓글 -1개 표시이전 댓글 -1개 숨기기
Ioannis Vourvachakis 2022년 7월 3일
Thank you Keshav, yes I want to focus on [-10,10], but I want to show that the x axis limits are bigger.

댓글을 달려면 로그인하십시오.

### 카테고리

Help CenterFile Exchange에서 Line Plots에 대해 자세히 알아보기

### Community Treasure Hunt

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

Start Hunting!

Translated by