Matlab画图时的线型、标记以及颜色简记
背景
使用Matlab画图的时候经常由于需要画图,但是总是忘了曲线颜色、线型以及标记,这里在这里记录下,方便查阅。
效果预览:
LineSpec —线型,标记和颜色。
线型,标记和颜色,指定为字符矢量或包含符号的字符串。 这些符号可以按任何顺序出现。 您无需指定所有三个特征(线条样式,标记和颜色)。 例如,如果省略线条样式并指定标记,则绘图仅显示标记而没有线。
线型
Line Style | Description |
---|---|
- | Solid line (default) |
– | Dashed line |
: | Dotted line |
-. | Dash-dot line |
标记
Marker | Description |
---|---|
o | Circle |
+ | Plus sign |
* | Asterisk |
. | Point |
x | Cross |
s | Square |
d | Diamond |
^ | Upward-pointing triangle |
v | Downward-pointing triangle |
> | Right-pointing triangle |
< | Left-pointing triangle |
p | Pentagram |
h | Hexagram |
颜色
Color | Description |
---|---|
y | yellow |
m | magenta |
c | cyan |
r | red |
g | green |
b | blue |
w | white |
k | black |
Example: ‘–or’ is a red dashed line with circle markers
例说
Modify Lines After Creation
Define x as 100 linearly spaced values between and . Define y1 and y2 as sine and cosine values of x. Create a line plot of both sets of data and return the two chart lines in p.
x = linspace(-2*pi,2*pi);
y1 = sin(x);
y2 = cos(x);
p = plot(x,y1,x,y2);
- 1
- 2
- 3
- 4
得到:
Change the line width of the first line to 2. Add star markers to the second line. Starting in R2014b, you can use dot notation to set properties. If you are using an earlier release, use the docid:matlab_ref.f67-432995 function instead.
p(1).LineWidth = 2;
p(2).Marker = '*';
- 1
- 2
文章来源: reborn.blog.csdn.net,作者:李锐博恩,版权归原作者所有,如需转载,请联系作者。
原文链接:reborn.blog.csdn.net/article/details/103778421
- 点赞
- 收藏
- 关注作者
评论(0)