当前位置:网站首页>Setting method of parameters such as color and linetype of MATLAB curve
Setting method of parameters such as color and linetype of MATLAB curve
2022-04-22 04:41:00 【The most important thing is to insist and never forget the orig】
Matlab The color of the curve 、 Parameter setting methods such as linetype
stay Matlab When drawing , If there are many curves drawn in the same window , It is usually necessary to distinguish them with different colors and linetypes , Otherwise, when printing and outputting the image in black and white , The user cannot distinguish curves with different attributes . The following is the configuration template of curve color , You can directly modify and use , Direct reference PlotStyle This data structure is OK .
Example 1
1 %% Matlab Linetype color setting template
2 clear;
3 close all;
4 %%-----------matlab The color of the drawn curve , Linetype , Thickness and other parameter setting methods ----------------
5 PlotStyle={
6 struct('Color',[1,0,0],'LineStyle','-'),...
7 struct('Color',[0,1,0],'LineStyle','-'),...
8 struct('Color',[0,0,1],'LineStyle','-'),...
9 struct('Color',[0,0,0],'LineStyle','-'),...%
10 struct('Color',[1,1,0],'LineStyle','-'),...%yellow
11 struct('Color',[1,0,1],'LineStyle','-'),...%pink
12 struct('Color',[0,1,1],'LineStyle','-'),...
13 struct('Color',[0.5,0.5,0.5],'LineStyle','-'),...%gray
14 struct('Color',[136,0,21]/255,'LineStyle','-'),...%dark red
15 struct('Color',[255,127,39]/255,'LineStyle','-'),...%orange
16 struct('Color',[0,162,232]/255,'LineStyle','-'),...%Turquoise
17 struct('Color',[163,73,164]/255,'LineStyle','-'),...%purple
18 struct('Color',[1,0,0],'LineStyle','--'),...
19 struct('Color',[0,1,0],'LineStyle','--'),...
20 struct('Color',[0,0,1],'LineStyle','--'),...
21 struct('Color',[0,0,0],'LineStyle','--'),...%
struct('Color',[1,1,0],'LineStyle','--'),...%yellow
22 struct('Color',[1,0,1],'LineStyle','--'),...%pink
23 struct('Color',[0,1,1],'LineStyle','--'),...
24 struct('Color',[0.5,0.5,0.5],'LineStyle','--'),...%gray
25 struct('Color',[136,0,21]/255,'LineStyle','--'),...%dark red
26 struct('Color',[255,127,39]/255,'LineStyle','--'),...%orange
27 struct('Color',[0,162,232]/255,'LineStyle','--'),...%Turquoise
28 struct('Color',[163,73,164]/255,'LineStyle','--'),...%purple
29 struct('Color',[1,0,0],'LineStyle','-.'),...
30 struct('Color',[0,1,0],'LineStyle','-.'),...
31 struct('Color',[0,0,1],'LineStyle','-.'),...
32 struct('Color',[0,0,0],'LineStyle','-.'),...%
33 struct('Color',[1,1,0],'LineStyle',':'),...%yellow
34 struct('Color',[1,0,1],'LineStyle','-.'),...%pink
35 struct('Color',[0,1,1],'LineStyle','-.'),...
36 struct('Color',[0.5,0.5,0.5],'LineStyle','-.'),...%gray
37 struct('Color',[136,0,21]/255,'LineStyle','-.'),...%dark red
38 struct('Color',[255,127,39]/255,'LineStyle','-.'),...%orange
39 struct('Color',[0,162,232]/255,'LineStyle','-.'),...%Turquoise
40 struct('Color',[163,73,164]/255,'LineStyle','-.'),...%purple
41 };
42 box on;
43 x = 0.1:.1:10;
44 len = length(PlotStyle);
45 for i = 1:len
46 y = x.*sin(x)+i*2;% Draw multiple parallel curves ,i*2 This term is the offset up and down the curve
47 hold on;
48 plot(x,y,'Color',PlotStyle{1,i}.Color,'LineStyle',PlotStyle{1,i}.LineStyle,'lineWidth', 2);% Here is the method to call the above template structure , Pay attention to the way of reference , One to one correspondence between attributes and values is required , Similar to key value pairs
49 end
50 title('Matlab Examples of multiple color and linetype settings ','FontSize',20,'FontWeight','bold','Color','k');
51 xlabel('x Axis ','FontSize',15,'FontWeight','bold','Color','k');
52 ylabel('y Axis ','FontSize',15,'FontWeight','bold','Color','k');
53
54 saveas(gcf, 'result', 'jpg')
Matlab The output is as follows :
版权声明
本文为[The most important thing is to insist and never forget the orig]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/04/202204220437497312.html
边栏推荐
- 2022P气瓶充装考试题库及模拟考试
- 队列总结(第一篇)
- goland汉化解决方法(下载插件失败的情况下)
- 仿真生成随机数计算生成每个同学生日
- 2022G2电站锅炉司炉操作证考试题库及在线模拟考试
- Queue II
- At32 MCU audio 24bit routine
- Statistics of authoritative institutions: the best data center network company in 2021, China Huawei and H3C, were listed
- Jupiter notebook modifying the default opening path
- 【S32K3_STM&PIT_MCAL】
猜你喜欢

【S32K3_STM&PIT_MCAL】

crypto-js加密算法库【安装教程、缓存加密】

What are the main aspects of mobile app testing?

Peer interview sharing Lenovo WinForm direction 20220420

2022年山东省安全员C证考试题及在线模拟考试

5_ Data analysis - Data Visualization

如何在 Acrobat Pro DC 与其它文件合并创建单个 PDF 文件?

企业数据防泄露方案分享

Unity simple UI prefix tree red dot system

How can devices of different brands be compatible and interconnected? Yiwen teaches you to understand
随机推荐
JVM tuning notes
matlab如何实现不同的值显示不同的颜色
2022p cylinder filling test question bank and simulation test
pycharm+anaconda安装包
kaggle實戰4.1--時間序列預測問題
[part of speech] 23. Modal verb 2 [have to] [out to] [dare] [be able to] [need n't]
SAP export material inventory code
链表第四篇
12.libevent循环函数和退出测试
一文告诉你分析即服务(AaaS)到底是什么
Revit data processing (III)
How did Jian Daoyun, who started a business in a small team of 10 people and now has an income of more than 100 million without financing, do it?
How expensive is the "salary" of software testing industry?
rpc error: code = Unavailable desc = error reading from server: EOF
Torch file saving and loading -- [torch learning notes]
Solution to Chinese translation of GoLand (in case of failure to download plug-ins)
C语言学习记录——삼십칠 字符串函数使用和剖析(1)
C entry - check the ID number with regular expressions.
论文阅读 (49):Big Data Security and Privacy Protection (科普文)
Job scheduling, intermediate scheduling, process scheduling