Matlab 曲线绘制之线型和颜色 示例
估计很多人会碰到,当绘制的曲线特别多的时候,需要用不同的颜色和线型区分开这些曲线。根据STC论文,自己整理了一个颜色和线型的例子,供大家直接使用,直接引用PlotStyle这个数据结构就可以了。
示例1
PlotStyle={
struct('Color',[1,0,0],'LineStyle','-'),...
struct('Color',[0,1,0],'LineStyle','-'),...
struct('Color',[0,0,1],'LineStyle','-'),...
struct('Color',[0,0,0],'LineStyle','-'),...% struct('Color',[1,1,0],'LineStyle','-'),...%yellow
struct('Color',[1,0,1],'LineStyle','-'),...%pink
struct('Color',[0,1,1],'LineStyle','-'),...
struct('Color',[0.5,0.5,0.5],'LineStyle','-'),...%gray-25%
struct('Color',[136,0,21]/255,'LineStyle','-'),...%dark red
struct('Color',[255,127,39]/255,'LineStyle','-'),...%orange
struct('Color',[0,162,232]/255,'LineStyle','-'),...%Turquoise
struct('Color',[163,73,164]/255,'LineStyle','-'),...%purple %%%%%%%%%%%%%%%%%%%%
struct('Color',[1,0,0],'LineStyle','--'),...
struct('Color',[0,1,0],'LineStyle','--'),...
struct('Color',[0,0,1],'LineStyle','--'),...
struct('Color',[0,0,0],'LineStyle','--'),...% struct('Color',[1,1,0],'LineStyle','--'),...%yellow
struct('Color',[1,0,1],'LineStyle','--'),...%pink
struct('Color',[0,1,1],'LineStyle','--'),...
struct('Color',[0.5,0.5,0.5],'LineStyle','--'),...%gray-25%
struct('Color',[136,0,21]/255,'LineStyle','--'),...%dark red
struct('Color',[255,127,39]/255,'LineStyle','--'),...%orange
struct('Color',[0,162,232]/255,'LineStyle','--'),...%Turquoise
struct('Color',[163,73,164]/255,'LineStyle','--'),...%purple %%%%%%%%%%%%%%%%%%%
struct('Color',[1,0,0],'LineStyle','-.'),...
struct('Color',[0,1,0],'LineStyle','-.'),...
struct('Color',[0,0,1],'LineStyle','-.'),...
struct('Color',[0,0,0],'LineStyle','-.'),...% struct('Color',[1,1,0],'LineStyle',':'),...%yellow
struct('Color',[1,0,1],'LineStyle','-.'),...%pink
struct('Color',[0,1,1],'LineStyle','-.'),...
struct('Color',[0.5,0.5,0.5],'LineStyle','-.'),...%gray-25%
struct('Color',[136,0,21]/255,'LineStyle','-.'),...%dark red
struct('Color',[255,127,39]/255,'LineStyle','-.'),...%orange
struct('Color',[0,162,232]/255,'LineStyle','-.'),...%Turquoise
struct('Color',[163,73,164]/255,'LineStyle','-.'),...%purple
};
x = 0.1:.1:10;
len = length(PlotStyle)
for i = 1:len
y = x.*log(x)+i*2;
hold on;
plot(x,y,'Color',PlotStyle{1,i}.Color,'LineStyle',PlotStyle{1,i}.LineStyle,'lineWidth', 2);%call method
end
title('多种颜色和线性的示例','FontSize',20,'FontWeight','bold','Color','k');
xlabel('x轴','FontSize',15,'FontWeight','bold','Color','k');
ylabel('y轴','FontSize',15,'FontWeight','bold','Color','k');
saveas(1, 'result', 'jpg');
效果如下图所示:

示例2
PlotStyle={
struct('Color',[,,]/,'LineStyle','-'),...
struct('Color',[,,]/,'LineStyle','--'),...
struct('Color',[,,]/,'LineStyle','-.'),...
struct('Color',[,,]/,'LineStyle',':'),...% struct('Color',[,,],'LineStyle','-'),...%yellow
struct('Color',[,,]/,'LineStyle','-')
};
x = :.:;
len = length(PlotStyle)
for i = :len
% y = x.*log(x)+i*;
y = x.*sin(x)+i*;
hold on;
plot(x,y,'Color',PlotStyle{,i}.Color,'LineStyle',PlotStyle{,i}.LineStyle,'lineWidth', );
end
title('多种颜色和线性的示例','FontSize',,'FontWeight','bold','Color','k');
xlabel('x轴','FontSize',,'FontWeight','bold','Color','k');
ylabel('y轴','FontSize',,'FontWeight','bold','Color','k');
saveas(, 'result2', 'jpg');
效果如下图所示:

示例3
clc;
close all;
%%数据生成
ya = [];
yb = [];
yc = [];
xa = [];
xb = [];
xc = [];
for i = :
value0 = i*+rand();
valuea = i*+rand();
xa = [xa value0];
ya = [ya *valuea.^(0.6)];
valueb = i*+rand();
xb = [xb valueb];
yb = [yb *valuea.^(0.7)];
valuec = i*+rand();
xc = [xc valuec];
yc = [yc *valuea.^(0.5)];
end
xa = xa - min(xa);
ya = ya - min(ya);
xb = xb - min(xb);
yb = yb - min(yb);
xc = xc - min(xc);
yc = yc - min(yc);
figure();
hold on;
axis equal %强制坐标轴尺度相同,这个放在前面或者后面效果会不一样
xlim([ ]);%x轴范围
ylim([ ]);%y轴范围 %%绘制曲线
plot(xa,ya,'ms:','LineWidth',,'MarkerSize',,'Color', [ ]);
x = xa(end);y = ya(end);
text(x-0.5,y+0.5,['(x_n,y_n)'],...
'FontSize',, 'Color',[0.0 0.0 0.0], 'FontWeight','bold');
plot(xb(:end-),yb(:end-),'ro:','LineWidth',,'MarkerSize',,'Color', [ ]);
x = xb(end-);y = yb(end-);
text(x-0.5,y+0.5,['(x_m,y_m)'],...
'FontSize',, 'Color',[0.0 0.0 0.0], 'FontWeight','bold');
plot(xc(:end-),yc(:end-),'r<:','LineWidth',,'MarkerSize',,'Color', [ ]);
x = xc(end-);y = yc(end-);
text(x-0.5,y+0.5,['(x_k,y_k)'],...
'FontSize',, 'Color',[0.0 0.0 0.0], 'FontWeight','bold'); %坐标原点
x = xc();y = yc();
text(x+0.5,y+0.5,['(x_0,y_0)'],...
'FontSize',, 'Color',[0.0 0.0 0.0], 'FontWeight','bold');
title('转归过程','FontSize',,'FontWeight','bold','FontName','微软雅黑'); %%坐标轴标题设置
xlabel('体质辨识x','Color','k','FontSize',,'FontWeight','bold','FontName','微软雅黑');%横轴标题
ylabel('疾病预报y','Color','k','FontSize',,'FontWeight','bold','FontName','微软雅黑');%纵轴标题 %设置legend
hleg = legend('体检者1','体检者2','体检者3','Location','NorthWest');%本身不能设置字体的大小,需要通过set进行设置
set(hleg,'FontSize', , 'FontAngle','italic','FontWeight','bold',...
'Color',[,,]);%Color为设置坐标的背景颜色 %%坐标轴刻度设置
set(gca, 'ytick',ya,'yticklabel',{' ',' ',' ',' ',' ',' ','','','',''},'xtick',x,...
'xticklabel',{'','','','','','','','','',''}, 'color',[ ],...
'FontSize',,'FontName','微软雅黑'); %xtick就是你要在哪些地方显示刻度,xticklabel就是显示什么内容 scrsz = get(,'ScreenSize');
set(gcf,'Position',scrsz); %%保存图像
set(, 'InvertHardCopy', 'off');%设置的背景色有效,如果为on则图形不保存背景色,maltab 默认为 on
filename = 'test';
saveas(,filename,'jpeg');
效果如下图所示:

Matlab 曲线绘制之线型和颜色 示例的更多相关文章
- [转帖]MATLAB曲线绘制及颜色类型
信号源产生的方法 来源:http://www.2cto.com/kf/201401/270494.html matlab的checkerboard说明,GOOD! 来源:http://www.chi ...
- MATLAB曲线绘制
一. 二维数据曲线图1.1 绘制 单根二维曲线plot 函数的基本调用 格式为:plot(x,y) 其中x和y为长度相同的向量,分别用于存储x坐标 和y坐标数据. 例1-1 在0≤x≤2p区间内,绘制 ...
- MATLAB 曲线形状,粗细,颜色使用大全
通过改变R-G-B 的值改变线条的颜色: $$\tt\Large plot(x,y,'Color',[R~~G~~B]);$$ 通过改变$c\in[1,+\infty)$的值改变线条的粗细 $$\tt ...
- matlab 画图中线型及颜色设置
matlab受到控制界广泛接受的一个重要原因是因为它提供了方便的绘图 功能.本章主要介绍2维图形对象的生成函数及图形控制函数的使用方 法,还将 简单地介绍一些图形的修饰与标注函数及操作和控制MATLA ...
- Matlab 如何绘制复杂曲线的包络线
Matlab 如何绘制复杂曲线的包络线 http://jingyan.baidu.com/article/aa6a2c14d36c710d4c19c4a8.html 如果一条曲线(比如声音波形)波动很 ...
- Matlab图形绘制
图形绘制 离散函数图形: 例:离散数据和离散函数可视化(离散数据作图方式) X1=[,,,,,,,,,,,,,,,,,,,]; Y1=[,,,,,,,,,,,,,,,,,,,]; figure() p ...
- ROC曲线绘制
ROC 曲线绘制 个人的浅显理解:1.ROC曲线必须是针对连续值输入的,通过选定不同的阈值而得到光滑而且连续的ROC曲线,故通常应用于Saliency算法评价中,因为可以选定0~255中任意的值进行阈 ...
- MATLAB中提供的线型属性
MATLAB中提供的线型属性有: 线型 说明 标记符 说明 颜色 说明 - 实线(默认) + 加号符 r 红色 -- 双划线 o 空心圆 g 绿色 : 虚线 * 星号 b 蓝色 :. 点划线 . 实心 ...
- C# 曲线控件 曲线绘制 实时曲线 多曲线控件 开发
Prepare 本文将使用一个NuGet公开的组件来实现曲线的显示,包含了多种显示的模式和配置来满足各种不同的应用场景,方便大家进行快速的开发系统. 在Visual Studio 中的NuGet管理器 ...
随机推荐
- 爬行百度标题&URL案例
思路: 先将需要获取的匹配出,然后可以用"永真"(即while True:)来遍历使得URL可以一直自增变化(百度点击下一页URL的pn参数就增加10)每增加10就爬行一遍URL然 ...
- [Leetcode] Sum 系列
Sum 系列题解 Two Sum题解 题目来源:https://leetcode.com/problems/two-sum/description/ Description Given an arra ...
- BAT-快速切换JDK1.6/1.7
Code: @echo OFF rem 修改背景/字体颜色为黑/绿 color 0A rem 自动设置JDK环境变量,本程序不会对 [系统环境变量] 造成破环!不需要重启!! rem 没有%%JAVA ...
- 142.Linked List Cycle II---双指针
题目链接 题目大意:141题目的扩展,给出单链表,判断是否有环,如果有环,找出环的开始的结点,如果没有环,返回null. 法一(借鉴):在已经找出单链表环的基础上再找开始结点,要时刻记住这个环不一定是 ...
- nginx报502修复日志
参考:https://www.baidu.com/link?url=PGd7mgvalnQp0MOVZTyDJIvr6_eJn1hmPlmsLpdj2vH6w3FzMt3pZEd_MKpoiqX1OF ...
- 查看wtmp(登陆信息的内容)
/var/log/wtmp文件的作用 /var/log/wtmp也是一个二进制文件,记录每个用户的登录次数和持续时间等信息. 查看方法: 可以用last命令输出当中内容: debi ...
- Codeforces 798D - Mike and distribution(二维贪心、(玄学)随机排列)
题目链接:http://codeforces.com/problemset/problem/798/D 题目大意:从长度为n的序列A和序列B中分别选出k个下表相同的数要求,设这两个序列中k个数和分别为 ...
- fiddler添加监测请求的 ip地址
本文转载自:http://www.jackness.org/2014/12/26/%E7%BB%99fiddler%E6%B7%BB%E5%8A%A0%E7%9B%91%E6%B5%8B%E8%AF% ...
- git - git命令中文显示乱码
使用git add添加要提交的文件的时候,如果文件名是中文,会显示形如897\232\350\256...的乱码,解决办法: git config --global core.quotepath ...
- 【原创】Scrapyd 的 .net 客户端
最近项目需要部署Scrapy爬虫,采用最简单的Scrapyd服务进行部署,基于.net core 进行了客户端的封装. 1)Scrapyd API文档:http://scrapyd.readthedo ...