Controlling the spacing between markers in a plot in a figure
Show older comments
How do I control the spaces between markers in a plot so that it although I am plotting say a 100,000 points but it shows markers at only sample points, and does not show markers when the plot drops between two points:
A sample is shown in figure below:
Thanks
Accepted Answer
More Answers (2)
Walter Roberson
on 24 Dec 2012
1 vote
plot() once without any markers on the line. Then scatter() the desired markers into place.
4 Comments
Sam Alex
on 24 Dec 2012
Walter Roberson
on 24 Dec 2012
? I did not say anything about random ?
The plots you gave as examples look to me to be straight lines between the markers, as if only those points had been plotted, a marker for each point.
Sam Alex
on 24 Dec 2012
Walter Roberson
on 24 Dec 2012
Yes, remember that plot(x,y) places the points at the given x locations. For example,
x = 0:1000:100000;
y = x.^2;
plot(x,y);
That will have an x axis from 0 to 100000 even though only 100 points are plotted.
Jacob Jonsson
on 22 May 2018
1 vote
I wrote a function available at: https://www.mathworks.com/matlabcentral/fileexchange/37165-plotsparsemarkers Should work with MATLAB versions that have 'MarkerIndices' as well as the older ones.
Categories
Find more on Annotations 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!