MATLAB修改坐标轴 gca

MATLAB修改坐标轴刻度的一些方法:

【原文链接】:

1、删除坐标轴刻度:

<span style="font-size:18px;">set(gca,'xtick',[])%去掉x轴的刻度

set(gca,'ytick',[]) %去掉xy轴的刻度

set(gca,'xtick',[],'ytick',[]) %同时去掉x轴和y轴的刻度</span>

2、不同风格的坐标轴:

x=1:8;

subplot(2,2,1)
plot(x)
                                                         %tick style 0(auto)

subplot(2,2,2)
plot(x)
set(gca,'xtick',[1 3 6 8]);                              %style 1
set(gca,'ytick',[]);                                     %style 2

subplot(2,2,3)
plot(x)
set(gca,'xtick',[1 3 6 8]);
set(gca,'xticklabel',sprintf('.4f|',get(gca,'xtick')));   %style 3
set(gca,'ytick',[2 4 5 7]);
set(gca,'yticklabel',{'Two','Four','Five','Seven'});      %style 4

subplot(2,2,4)
plot(x)
set(gca,'xminortick','on');                               %style 5
set(gca,'ticklength',[0.05 0.025]);                       %style 6
set(gca,'tickdir','out');%style 7


3、MATLAB调整坐标

x=20:10:20000;
y=rand(size(x));
semilogx(x,y);
set(gca,'XLim',[20 20000]);
set(gca,'XMinorTick','off');
set(gca,'XTick',[20 31.5 63 125 250 500 1000 2000 4000 8000 16000]);
set(gca,'XGrid','on');
set(gca,'XMinorGrid','off');


4、 MATLAB坐标刻度调整
subplot(3,2,1)

plot(x)

title('默认格式')

subplot(3,2,2)

plot(x)

set(gca,'xtick',[1 3 6 8]);

set(gca,'ytick',[]);

title('X自定义间隔,Y关闭')

subplot(3,2,3)

plot(x)

set(gca,'xtick',[1 3 6 8]);

set(gca,'xticklabel',sprintf('.4f|',get(gca,'xtick')))

set(gca,'ytick',[2 4 5 7]);

set(gca,'yticklabel',{'Two','Four','Five','Seven'});

title('XY自定义间隔、精度及显示方式')

subplot(3,2,4)

plot(x)

set(gca,'xminortick','on');%style 5

set(gca,'ticklength',[0.05 0.025]);

set(gca,'tickdir','out');

title('XY坐标刻度显示方式')

subplot(3,2,5)

plot(x)

set(gca,'xtick',[min(x) (max(x)+min(x))/2 max(x)]);

set(gca,'ytick',[min(x) (max(x)+min(x))/2 max(x)]);

title('论文中常用的标准3点式显示')

x=20:10:20000;

y=rand(size(x));

subplot(3,2,6)

semilogx(x,y);

set(gca,'XLim',[20 20000]);

set(gca,'XMinorTick','off');

set(gca,'XTick',[20 31.5 63 125 250 500 1000 2000 4000 8000 16000]);

set(gca,'XGrid','on');

set(gca,'XMinorGrid','off');

title('自定义网格显示')

%%%%%%%%%%%%%%%%%%%%%%

%顺便附上可以格式化坐标刻度的程序段

x=get(gca,'xlim');

y=get(gca,'ylim');

set(gca,'xtick',[x(1) (x(1)+x(2))/2 x(2)]);

set(gca,'ytick',[y(1) (y(1)+y(2))/2 y(2)]);

-------------




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

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值