-
大小: 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
相关资源
- matlab_OFDM调制解调(来自剑桥大学)
- Matlab路面裂缝识别69319
- 高灵敏度GPS接收机MATLAB仿真,附捕获
- 基于MATLAB的质点弹道计算与外弹道优
- 阵列天线的matlab仿真
- MATLAB 经典程序源代码大全
- MATLAB小波软阈值去噪代码33473
- 天线阵的波束形成在MATLAB仿真程序及
- 非线性SVM算法-matlab实现
- 《MATLAB 智能算法超级学习手册》-程序
- 组合导航matlab程序
- 读取txt文件内容matlab代码实现
- Matlab实现基于相关的模板匹配程序
- matlab优化工具箱讲解
- 基于MATLAB的快速傅里叶变换
- 光纤传输中的分布傅立叶算法matlab实
- 基于matlab的图像处理源程序
- matlab 椭圆拟合程序
- 算术编码解码matlab源代码
- optical_flow 光流法 matlab 实现程序
- 引导图像滤波器 Matlab实现
- 分形几何中一些经典图形的Matlab画法
- OFDM系统MATLAB仿真代码
- SVM工具箱(matlab中运行)
- 图像小波变换MatLab源代码
- LU分解的MATLAB实现
- 冈萨雷斯数字图像处理matlab版(第三
- 替代数据法的matlab程序
- 用matlab实现的多站定位系统性能仿真
- 通过不同方法进行粗糙集属性约简m
评论
共有 条评论