Updated 22 May 2018
[h =] plotsparsemarkers(hp, hl, markerStyle[, numberOfMarkers = 6 [,staggered = true]])
The function takes the handle returned from a plot call and adds a few markers along each line rather than the default of one marker per x-value.
The type of marker has to be given for each line you want a marker on.
The legend is also updated assuming that the handle to it is given.
For plots with multiple lines the markers are staggered between the lines so that they wont exactly line up (and possibly cover each other). This feature can be turned off if you want aligned values.
The function returns a handle to the new "lines" to allow further manipulation.
plotsparsemarkersdemo.m is a simple demonstration of the functionality. It should be very easy to get up and running with this.
Jacob Jonsson (2023). plotsparsemarkers (https://www.mathworks.com/matlabcentral/fileexchange/37165-plotsparsemarkers), MATLAB Central File Exchange. Retrieved .
MATLAB Release Compatibility
Platform CompatibilityWindows macOS Linux
- MATLAB > Graphics > 2-D and 3-D Plots > Line Plots > Two y-axis >
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!Start Hunting!
Discover Live Editor
Create scripts with code, output, and formatted text in a single executable document.
Made code compatible with 'MarkerIndices' attribute of the lines instead of old way. Not sure in which version this was added, the split is hard coded in the statement