% H = colormapline(X,Y,Z,C) Plot a line using a specified colormap
% If Z is given, a 3D plot with coordinates X, Y, Z is created.
% If Z is not given, a 2D plot of Y over X if created.
% If Y and Z are not given, a 2D plot of X over 1:length(X) is created.
% The plotted line uses all colors in a given colormap in ascending
% order. Other than with other functions in File Exchange, the color
% does NOT depend on any coordinate.
% Technically, length(colormap) lines are plotted, each with a different
% color from the colormap in ascending order.
% H is a handle to the complete colored line. It can be used to set
% parameters such as linewidth and linestyle.
% C is optional. If it is specified, it is used as a colormap. To use it
% with a 2D plot, use Z= and Y= if required;
%% 2D plot
%% 3D plot
%% Minimal example (2D plot with one input)
%% 2D plot using MarkerFaceColor
% Version 2.1, 2016-12-14
% Change from version 2 (2013-01-29):
% - Line property 'MarkerFaceColor' is now also set using the colormap.
% Behaviour of previous versions can be restored by running the
% following line after the call:
% This change was triggered by Nathan's question from 04 April 2016.
@Nathan: I just uploaded a new version which also sets MarkerFaceColor. This is the only change in the new version.
Thanks! This works great for me
Very nice. Is there anyway to get MarkerFaceColor to be the same as MarkerEdgeColor?
This is what I'm looking for.
To get the lightness for jet in my previous snippet, I used this code:
lab2 = colorspace('RGB->Lab',jet(256));
and this submission:
Works well for me. For eample I used this code:
to get the first figure in this post:
Line property 'MarkerFaceColor' is now also set using the colormap.
fixed small bugs and slightly enhanced the funtionality
Download apps, toolboxes, and other File Exchange content using Add-On Explorer in MATLAB.