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管理器 ...
随机推荐
- 【会装】kylin的安装(填坑)和简单使用
1.简介 kylin的设计思想是空间换时间,将hive上的大表的维度全部排列组合计算也将度量提前计算然后存入HBase库,这个步骤在kylin中称之为build cube. 在查询的时候已经建立cu ...
- Linux 基础——权限管理命令chown、chgrp
一.chown命令与chgrp命令的作用 有时你需要改变文件或目录的属主,比如有人离职或开发人员创建了一个在测试或生产环境中需要归属在系统账户下的应用.Linux提供了两个命令来实现这个功能:chow ...
- 小甲鱼Python笔记(类)
类和对象 类的构造方法 def __init__(): 1 class People: 2 def __init__(self,name): 3 self.name = name 注意:在构造方法中的 ...
- 深入理解JS各种this指向问题
说到this,入前端坑的人都知道这是JS初期语言毕竟之路.很多人(我就是)对于this的了解很模糊,或者不够全面.最近打算在反过来在看下es6,在es6中又出现了箭头函数对于this的理解有多了层认识 ...
- Cookie机制和Session机制
1. cookie 1. Cookie 是在HTTP协议下,服务器或脚本可以维护客户工作站上信息的一种方式.Cookie 是由 Web服务器保存在用户浏览器(客户端)上的小文本文件(内容通常经过加密) ...
- Windows 10家庭版远程桌面连接错误
由于需要操作远程服务器,经常使用“远程桌面连接”工具,一直很正常.今天突然提示 出现身份验证错误,可能是由于 CredSSP加密Oracle修正.什么情况!! 根据提示的地址https://go.mi ...
- Codeforces Round #278 (Div. 1) B - Strip dp+st表+单调队列
B - Strip 思路:简单dp,用st表+单调队列维护一下. #include<bits/stdc++.h> #define LL long long #define fi first ...
- bzoj 1131 简单树形dp
思路:随便想想就能想出来啦把... 卡了我一个vector... #include<bits/stdc++.h> #define LL long long #define fi firs ...
- shell-sed命令详解(转)
(转自http://blog.csdn.net/wl_fln/article/details/7281986) Sed简介 sed是一种在线编辑器,它一次处理一行内容.处理时,把当前处理的行存储在临时 ...
- pip安装报错解决
使用pip安装docker-compose时报 unsupported operand type(s) for -=: 'Retry' and 'int' 错误,经过一番google后,发现使用升级s ...