Code covered by the BSD License  

Highlights from
CMAPLINE

4.0

4.0 | 2 ratings Rate this file 18 Downloads (last 30 days) File Size: 2.5 KB File ID: #21102
image thumbnail

CMAPLINE

by

 

15 Aug 2008 (Updated )

apply a colormap to lines in a plot

| Watch this File

File Information
Description

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
x=(0:0.1:2*pi);
m=50; exdata=bsxfun(@plus,repmat(25.*sin(x),...
[m 1]),[1:m]');

figure
subplot(121);
plot(x,exdata,'o-','linewidth',2)
cmapline('colormap','jet');
set(gca,'color','k')
title('jet colormap')
 
subplot(122);
plot(x,exdata,'o-','linewidth',2)
custommap=flipud(hot);
cmapline('colormap',custommap,'filled')
set(gca,'color','k')
title('reverse hot colormap, filled markers')

Acknowledgements

Varycolor inspired this file.

MATLAB release MATLAB 7.6 (R2008a)
Tags for This File   Please login to tag files.
Please login to add a comment or rating.
Comments and Ratings (5)
10 Mar 2012 Stefano  
21 Jul 2011 Wolfgang Schwanghart

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

cellfun(@(x,y)(set(x,'color',y)),lh(:),colrs);

29 Nov 2008 Ryan Ollos

@ 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.

16 Sep 2008 Andrew Stevens

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).

20 Aug 2008 Carlos Adrian Vargas Aguilera

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
>> CMAPLINE(COLORMAP) % string or hfunction or Mx3
>> CMAPLINE(AH,...) % single axes handle or
>> CMAPLINE(LH,...) % line handles (1 or more)

Well done, Carlos

Updates
16 Sep 2008

added capability of filling markers, updated help

16 Sep 2008

add handle of line objects as optional output, as suggested by Carlos.

29 Oct 2008

updated help so that the example will run properly, description

Contact us