colormapline - color-changing 2D or 3D line

버전 2.1.0.0 (4.38 KB) 작성자: Matthias Hunstig
Plot a 2D or 3D line using a specified colormap.
다운로드 수: 1.8K
업데이트 날짜: 2016/12/14

라이선스 보기

% 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;
%
% Examples:
%% 2D plot
% t=0:0.1:10*pi;
% h=colormapline(t.*sin(t),t.*cos(t),[],jet(128));
% set(h,'linewidth',3,'linestyle','--')
%
%% 3D plot
% t=-20*pi:0.1:20*pi;
% h=colormapline(t.*sin(t),t.*cos(t),sin(t),jet(128));
% set(h,'linewidth',3)
%
%% Minimal example (2D plot with one input)
% h=colormapline(1:1000);
%
%% 2D plot using MarkerFaceColor
% t=0:0.1:10*pi;
% h=colormapline3(t.*sin(t),t.*cos(t),[],jet(128));
% set(h,'Marker','o','LineStyle','none')
% 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:
% set(H,'MarkerFaceColor','none')
% This change was triggered by Nathan's question from 04 April 2016.

인용 양식

Matthias Hunstig (2024). colormapline - color-changing 2D or 3D line (https://www.mathworks.com/matlabcentral/fileexchange/39972-colormapline-color-changing-2d-or-3d-line), MATLAB Central File Exchange. 검색됨 .

MATLAB 릴리스 호환 정보
개발 환경: R2013b
모든 릴리스와 호환
플랫폼 호환성
Windows macOS Linux
카테고리
Help CenterMATLAB Answers에서 Colormaps에 대해 자세히 알아보기

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!
버전 게시됨 릴리스 정보
2.1.0.0

Line property 'MarkerFaceColor' is now also set using the colormap.

1.1.0.0

fixed small bugs and slightly enhanced the funtionality

1.0.0.0