Matlab作图及图形格式设置

通过汇总个人作图常用操作收藏集(包括[Plot][1]和[axis][2]设置),实现信息共享,便于日后向Python Matplotlib举一反三。

目录


作图流程:

Created with Raphaël 2.1.2 数据(x,y) plot settings 确认? 输出图形 yes no

Matlab相关文档

Plot —— [ 2-D line Plot ]

Axis ——[Axes Properties]

plot函数

plot的用法示例

1、plot(_,Name,Value) :常用于设置线条,将[Plot之LineSpec线条的设置]转化为键值对形式使用
2、plot(X1,Y1,LineSpec1,…,Xn,Yn,LineSpecn)

x = 0:pi/10:2*pi;
y1 = sin(x);
y2 = sin(x-0.25);
y3 = sin(x-0.5);

figure
plot(x,y1,'g',x,y2,'b--o',x,y3,'c*')

3、plot(ax,_)

figure % new figure
ax1 = subplot(2,1,1); % top subplot
ax2 = subplot(2,1,2); % bottom subplot
x = linspace(0,3);
y1 = sin(5*x);
y2 = sin(15*x);

plot(ax1,x,y1)
title(ax1,'Top Subplot')
ylabel(ax1,'sin(5x)')

plot(ax2,x,y2)
title(ax2,'Bottom Subplot')
ylabel(ax2,'sin(15x)')

4、h = plot(_)

x = linspace(-2*pi,2*pi);
y1 = sin(x);
y2 = cos(x);
p = plot(x,y1,x,y2);
p(1).LineWidth = 2;
p(2).Marker = '*';

Plot之LineSpec(线条的设置)

-Line Style
线型描述
-默认值(实线)
虚线
点线
-.虚线-点线
-Marker
标识描述标识描述
o^上三角
+v下三角
*星号<左三角
.>右三角
xp五角星
s正方形h六角星
d方片
-Color
颜色描述颜色描述
g绿色r红色
b蓝色m洋红
k黑色c青色
y黄色w白色
-LineWidth:(默认值10)
-MarkerSize:(默认值6)

设置坐标图的格式

利用句柄、键值对的形式设置坐标图格式
例如:

ax=gca;%获得当前坐标图对象的属性,即获取句柄
set(ax,'color','r');%更改坐标图底色
set(ax,'xcolor','g');%设置轴线、轴标签、刻度值颜色

键值对设置

-Appearance

Color

LineWidth (轴轮廓、刻度线、网格线,默认值0.5)
-Individual Axes Appearance

XAxisLocation (bottom,top,origin)
XColor
XLim

-Tick Value and label

XTick
XTickLabel
XTickLabelRotation (设置旋转角度)
xlabel

-Grid

XGrid
GridLineStyle
GridColor
GridAlpha(默认值:0.15)

-Font

FontName(’宋体’,’Times New Romance’)
FontSize(默认值:10)
FontWeight (normal,bold)

-Title,Axis and Legend

title
legend

title('My Title','FontWeight','normal')
ylabel('My y-Axis Label','FontSize',12)
legend({'Line 1','Line 2','Line 3'},'FontSize',12)
  • 2
    点赞
  • 8
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值