Allows control of nr of markers, and positioning uniformly along x or along the curve, and with the option to lock on a local max.
Accept same inputs as the LINE command, with the additional parameter NUM_MARKERS, specifying how many markers to be plot.
Inspired by the first answer given by Ioannis Filippidis on
Great function! However, I discovered one problem: If I plot x vs y and y is only zeros, the interp1 function encounters a problem. Replacing line 94 with the following solved the problem for me (The result becomes nan and not inf, since one divides 0 by 0):
Thanks for the attribution. For posterity, the function that I mentioned in that thread is here: https://github.com/johnyf/plot_utils/blob/bd304279ee0e000f72fc936e0ef9f3a690d4e654/plot_subsample/plot_fewer_markers.m
I am new to Matlab so I don't feel I'm qualified to give a rating or strong comments yet, but this has been very useful to me in achieving an important plot that seems to be almost inexplicably unnatural to achieve with Matlab.
Massimo, could you tell me whether or not it is possible to show only the markers in the legend rather than the markers in addition to the line style? I ask because my plot is only black and white with the same lines style for every curve, and I imagine this isn't uncommon for publications. The preferred legend for this style shows only the markers.
11 Jul 2013
- better formatted text indentation
- fixed few typos in comments
- added abbreviations for marker specs (mk,mks,mfc)
06 Aug 2013
to inhibit linestyle to show in legend.
20 Aug 2013
- added compatibility for column vector input
17 Oct 2014
- Added support for logarithmic X spacing of markers
- Added example on how to use it with plotyy