-
大小: 4KB文件类型: .zip金币: 2下载: 5 次发布日期: 2021-05-23
- 语言: Matlab
- 标签: linspecer.m Matlab 画图颜色
资源简介
Matlab画的线较多时,线的颜色的选取对图的美观是有很大的影响的。
Jonathan C. Lansey提供了在不同线上画不同颜色简单易用的函数。
代码片段和文件信息
% function linestyles = linspecer(N)
% This function creates an Nx3 array of N [R B G] colors
% These can be used to plot lots of lines with distinguishable and nice
% looking colors.
%
% linestyles = linspecer(N); makes N colors for you to use: linestyles(ii:)
%
% colormap(linspecer); set your colormap to have easily distinguishable
% colors and a pleasing aesthetic
%
% linestyles = linspecer(N‘qualitative‘); forces the colors to all be distinguishable (up to 12)
% linestyles = linspecer(N‘sequential‘); forces the colors to vary along a spectrum
%
% % Examples demonstrating the colors.
%
% LINE COLORS
% N=6;
% X = linspace(0pi*31000);
% Y = bsxfun(@(xn)sin(x+2*n*pi/N) X.‘ 1:N);
% C = linspecer(N);
% axes(‘NextPlot‘‘replacechildren‘ ‘ColorOrder‘C);
% plot(XY‘linewidth‘5)
% ylim([-1.1 1.1]);
%
% SIMPLER LINE COLOR EXAMPLE
% N = 6; X = linspace(0pi*31000);
% C = linspecer(N)
% hold off;
% for ii=1:N
% Y = sin(X+2*ii*pi/N);
% plot(XY‘color‘C(ii:)‘linewidth‘3);
% hold on;
% end
%
% COLORMAP EXAMPLE
% A = rand(15);
% figure; imagesc(A); % default colormap
% figure; imagesc(A); colormap(linspecer); % linspecer colormap
%
% See also NDHIST NHIST PLOT COLORMAP 43700-cubehelix-colormaps
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% by Jonathan Lansey March 2009-2013 ?Lansey at gmail.com %
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%
%% credits and where the function came from
% The colors are largely taken from:
% http://colorbrewer2.org and Cynthia Brewer Mark Harrower and The Pennsylvania State University
%
%
% She studied this from a phsychometric perspective and crafted the colors
% beautifully.
%
% I made choices from the many there to decide the nicest once for plotting
% lines in Matlab. I also made a small change to one of the colors I
% thought was a bit too bright. In addition some interpolation is going on
% for the sequential line styles.
%
%
%%
function linestyles=linspecer(Nvarargin)
if nargin==0 % return a colormap
linestyles = linspecer(128);
return;
end
if ischar(N)
linestyles = linspecer(128N);
return;
end
if N<=0 % its empty nothing else to do here
linestyles=[];
return;
end
% interperet varagin
qualFlag = 0;
colorblindFlag = 0;
if ~isempty(varargin)>0 % you set a parameter?
switch lower(varargin{1})
case {‘qualitative‘‘qua‘}
if N>12 % go home you just can‘t get this.
warning(‘qualitiative is not possible for greater than 12 items please reconsider‘);
else
if N>9
warning([‘Default may be nicer for ‘ num2str(N) ‘ for clearer colors use: whitebg(‘‘black‘‘); ‘]);
end
end
qualFlag = 1;
case {‘sequential‘‘seq‘}
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
文件 8449 2015-09-16 11:57 linspecer.m
文件 1318 2015-09-16 11:57 license.txt
相关资源
- Pattern Recognition and Machine Learning(高清
- MATLAB 编程 第二版 Stephen J. Chapman 著
- 均值滤波和FFT频谱分析Matlab代码
- 《MATLAB扩展编程》代码
- HDB3码、AMI码的MATLAB实现
- 3点GPS定位MATLAB仿真
- MATLAB数字信号处理85个实用案例精讲入
- matlab从入门到精通pdf94795
- 欧拉放大论文及matlab代码
- 跳一跳辅助_matlab版本
- 全面详解LTE MATLAB建模、仿真与实现
- MIMO-OFDM无线通信技术及MATLAB实现_孙锴
- MATLAB Programming for Engineers 4th - Chapman
- matlab 各种谱分析对比
- 分数阶chen混沌matlab程序
- 基于粒子群算法的非合作博弈的matl
- MATLAB车流仿真 包括跟驰、延误
- matlab空间桁架计算程序
- 基于MATLAB的图像特征点匹配和筛选
- DMA-TVP-FAVAR
- GPS信号的码捕获matlab代码.7z
- 一维光子晶体MATLAB仿真代码吸收率折
- newmark法源程序
- 传统关联成像、计算鬼成像matlab
- pri传统分选算法
- 摆动滚子推杆盘形凸轮设计
- 医学图像重建作业matlab源码
- Matlab实现混沌系统的控制
- 检测疲劳驾驶
- Matlab锁相环仿真-Phase Locked Loop.rar
评论
共有 条评论