python matlabplot 如何使得上下无间距_matlab基础绘图

1.基础绘图

和python类似

1.1 绘图:plot()

如果绘制多条曲线,需要使用hold on-hold off ,不然后面的曲线会覆盖掉前面的。

hold on

plot(cos(0:pi/20:2*pi),'o-k');

plot(sin(0:pi/20:2*pi),'X--b');

hold off%两个一起画;不使用hold on的话,默认会覆盖掉前面那张图片

604257794e9fd4df3973597680e29bbf.png

1.2 样式

plot样式

plot(x,y,‘str’)

17b1e36a483366720e5c32747558b24c.png

图例:legend()

title()和xlabel()ylabel()zlabel()

x=0:0.5:4*pi;

y=sin(x);

h=cos(x);

w=1./(1+exp(-x));

xlabel('t=0 tp 2\pi');

ylabel('values of sin(t) and e^{-x}');

plot(x,y,'bd-',x,h,'gp:',x,w,'ro-',x,w,'c^-');%样式

title('values of sin(t) and e^{-x}');%标题

legend('sin(x)','cos(x)','sigmoid','Gauss function');%图例

c12a85770afc30dcf5250bafe202f31a.png

text() and annotation()

数学公式使用latex

x = linspace(0,3);

y = x.^2.*sin(x);

plot(x,y);

line([2,2],[0,2^2*sin(2)]);

str = '$$ \int_{0}^{2} x^2\sin(x) dx $$';%表示积分函数

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值