could anyone tell me how to have equal spacing of selected numbers with respect to axis.
Show older comments
could anyone tell me how to have equal spacing of selected numbers with respect to axis with respect to the command line
set(gca, 'XTick', [0, 1, 2, 23,24]);
I want to have equal spacing between 0,1,2,23 and 24 with respect to x axis.
2 Comments
Walter Roberson
on 28 Mar 2018
The data you are plotting, are the x values for it only 0, 1, 2, 23 and 24, and nothing else?
Is it necessary that the data cursor should show the 24 when it is over information in that range, or is it okay if the data cursor can be wrong?
... And you are still using R2015b, right?
Prabha Kumaresan
on 29 Mar 2018
Accepted Answer
More Answers (2)
Sergey Kasyanov
on 28 Mar 2018
You can compress data between 2 and 23 ticks roughly by
%before plotting
XData(XData>2&XData<23)=(XData(XData>2&XData<23)-2)/(23-2)+2;
XData(XData>=23)=XData(XData>=23)-(23-2)+1;
%plotting code
plot(XData,YData)
%renaming of ticks
set(gca, 'XTick', [0, 1, 2, 3,4]);
set(gca,'XTickLabel',num2str([0;1;2;23;24]))
9 Comments
Prabha Kumaresan
on 28 Mar 2018
Prabha Kumaresan
on 28 Mar 2018
Walter Roberson
on 28 Mar 2018
It is difficult to be of assistance without answers to my questions, above.
Sergey Kasyanov
on 29 Mar 2018
Edited: Sergey Kasyanov
on 29 Mar 2018
I don't have the same problem.
Maybe last line in the code should be replaced by:
set(gca,'XTickLabel',{'0','1','2','23','24'})
Inform me if this is right way, please.
Sergey Kasyanov
on 29 Mar 2018
I advise you to check the answer below. It is accepted solution for this problem.
Prabha Kumaresan
on 29 Mar 2018
Edited: Walter Roberson
on 29 Mar 2018
Sergey Kasyanov
on 29 Mar 2018
I download your graph.fig which contains also three points: 1, 2 ,3. You should try to plot graph with larger amount of points.
Sergey Kasyanov
on 29 Mar 2018
Also you can use command
xlim([0,24])
to strech axis.
Prabha Kumaresan
on 29 Mar 2018
Image Analyst
on 29 Mar 2018
0 votes
Try this to find File Exchange submissions that allow a "break" in the axes: https://www.mathworks.com/matlabcentral/fileexchange/?utf8=%E2%9C%93&term=broken+axis

Categories
Find more on Get Started with MATLAB in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!