matlabplot用指定颜色_matlabplot用指定颜色_如何指定网格线颜色Matlab的

另一种方法是使用内置的网格:

h=gca;

grid on % turn on major grid lines

grid minor % turn on minor grid lines

% Set limits and grid spacing separately for the two directions:

h.XAxis.Limits=[-1,1];

h.XAxis.TickValues=-1:0.5:1;

h.XAxis.MinorTickValues=-1:0.2:1;

h.YAxis.Limits=[-1,1];

h.YAxis.TickValues=-1:0.5:1;

h.YAxis.MinorTickValues=-1:0.2:1;

% Must set major grid line properties for both directions simultaneously:

h.GridLineStyle='-'; % the default is some dotted pattern, I prefer solid

h.GridAlpha=1; % the default is partially transparent

h.GridColor=[0,0,0]; % here's the color for the major grid lines

% Idem for minor grid line properties:

h.MinorGridLineStyle='-';

h.MinorGridAlpha=1;

h.MinorGridColor=[1,0,0]; % here's the color for the minor grid lines

注意,您可以缩短以上代码通过一次设置多个属性:

h=gca;

grid on

grid minor

set(h.XAxis,'Limits',[-1,1],'TickValues',-1:0.5:1,'MinorTickValues',-1:0.2:1)

set(h.YAxis,'Limits',[-1,1],'TickValues',-1:0.5:1,'MinorTickValues',-1:0.2:1)

set(h,'GridLineStyle','-','GridAlpha',1,'GridColor',[0,0,0])

set(h,'MinorGridLineStyle','-','MinorGridAlpha',1,'MinorGridColor',[1,0,0])

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值