CMAPLINE finds all lines in an axis and specifies their colors according to a colormap. Also accepts custom colormaps in the form of a n x 3 matrix.
EXAMPLE (generates screenshot)
%generate some data
title('reverse hot colormap, filled markers')
Andrew Stevens (2020). CMAPLINE (https://www.mathworks.com/matlabcentral/fileexchange/21102-cmapline), MATLAB Central File Exchange. Retrieved .
Does what it says on the box. Very handy. Thanks!
If used with the 'lines' option, cmaplines returns an error if the linehandles are supplied as row vector. This can be avoided by changing line 152
@ Carlos: "I think this was the idea of VARYCOLOR, but it missed it."
I don't see this as being the case. The purpose of VARYCOLOR is to create a colormap with maximum color variation. The purpose of this function seems to be applying a colormap to lines in an axes. They seem to have completely different purposes.
Carlos, thanks for your comments. I recently updated the file to incorporate your suggestions (though my handling of input arguements is still a bit crude).
I think this was the idea of VARYCOLOR, but it missed it. Andrew, it would be nice to have the handle lines as an optional input. An a question: Why gcf is an specified axes handle? An idea could be:
>> CMAPLINE(COLORMAP) % string or hfunction or Mx3
>> CMAPLINE(AH,...) % single axes handle or
>> CMAPLINE(LH,...) % line handles (1 or more)
Well done, Carlos
updated help so that the example will run properly, description
add handle of line objects as optional output, as suggested by Carlos.
added capability of filling markers, updated help