5.0

5.0 | 1 rating Rate this file 198 downloads (last 30 days) File Size: 8.38 KB File ID: #14677

cline

by Sebastian Hölz

 

16 Apr 2007 (Updated 16 Apr 2007)

Code covered by BSD License  

Draw a colored line in 2D or 3D

Download Now | Watch this File

File Information
Description

There are several files on the FEX which deal with the plotting of colored lines, but they all have some drawbacks. I wrote a little file, which extends the scope of the submission by Kun Liu (s. below, hoping to deliver a general purpose file, which should work for most purposes.

SYNTAX
======
h = cline(x, y [, z, cdata])

INPUT
=====
x: vector with x-values
y: vector with y-values
z (opt.): vector with z-values
cdata (opt.): vector with color-data

2 input arguments => cdata = y; z=0
3 input arguments => cdata = z
4 i.a. & z = [] => cdata = y; z=0

OUPUT
=====
h: Handle to line (i.e. patch-object !!!)

Examples
========
t = 2*pi:.1:8*pi;

cline(sqrt(t).*sin(t), sqrt(t).*cos(t));
cline(sqrt(t).*sin(t), sqrt(t).*cos(t), t);
cline(sqrt(t).*sin(t), sqrt(t).*cos(t), t, rand(size(t))); view(3)
cline(sqrt(t).*sin(t), sqrt(t).*cos(t), [], rand(size(t))); view(3)

OK, hope you find this file useful

Sebastian

Acknowledgements

The author wishes to acknowledge the following in the creation of this submission:
Linear 2D Plot with Rainbow Color

MATLAB release MATLAB 7.0.4 (R14SP2)
Other requirements none
Zip File Content  
Other Files Cline_Example.png,
cline.m
Tags for This File  
Everyone's Tags
Tags I've Applied
Add New Tags Please login to tag files.
Comments and Ratings (1)
26 Jun 2007 Matt Bennett  
Please login to add a comment or rating.
Tag Activity for this File
Tag Applied By Date/Time
specialized Sebastian Hölz 22 Oct 2008 09:09:42
plotting Sebastian Hölz 22 Oct 2008 09:09:42
line Sebastian Hölz 22 Oct 2008 09:09:42
2d Sebastian Hölz 22 Oct 2008 09:09:42
3d Sebastian Hölz 22 Oct 2008 09:09:42
colored Sebastian Hölz 22 Oct 2008 09:09:42
graphics Sebastian Hölz 22 Oct 2008 09:09:42
 

MATLAB Central Terms of Use

NOTICE: Any content you submit to MATLAB Central, including personal information, is not subject to the protections which may be afforded information collected under other sections of The MathWorks, Inc. Web site. You are entirely responsible for all content that you upload, post, e-mail, transmit or otherwise make available via MATLAB Central. The MathWorks does not control the content posted by visitors to MATLAB Central and, does not guarantee the accuracy, integrity, or quality of such content. Under no circumstances will The MathWorks be liable in any way for any content not authored by The MathWorks, or any loss or damage of any kind incurred as a result of the use of any content posted, e-mailed, transmitted or otherwise made available via MATLAB Central. Read the complete Terms prior to use.

Contact us at files@mathworks.com