matlab 画图的坐标设置
2016-05-15 13:45
531 查看
1、坐标轴删除
set(gca,'xtick',[])%去掉x轴的刻度
set(gca,'ytick',[]) %去掉xy轴的刻度
set(gca,'xtick',[],'ytick',[]) %同时去掉x轴和y轴的刻度
--------------------
set(gca,'xticklabel',[])
set(gca,'yticklabel',[])
只去掉刻度,不去掉坐标轴
--------------------
2、Matlab中“坐标轴刻度”的不同风格
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
另附Maltab坐标调整程序一段:
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');
3、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)]);
-------------
get(gca,'xlim');是获取最大最小刻度的
如果需要获取所有在坐标轴上显示的刻度,需要使用get(gca,'ytick')
set(gca,'xtick',[])%去掉x轴的刻度
set(gca,'ytick',[]) %去掉xy轴的刻度
set(gca,'xtick',[],'ytick',[]) %同时去掉x轴和y轴的刻度
--------------------
set(gca,'xticklabel',[])
set(gca,'yticklabel',[])
只去掉刻度,不去掉坐标轴
--------------------
2、Matlab中“坐标轴刻度”的不同风格
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
另附Maltab坐标调整程序一段:
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');
3、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)]);
-------------
get(gca,'xlim');是获取最大最小刻度的
如果需要获取所有在坐标轴上显示的刻度,需要使用get(gca,'ytick')
相关文章推荐
- MATLAB画向量图
- MATLAB画ROC曲线,及计算AUC值
- utilities(matlab)—— 图像加噪
- utilities(matlab)—— PSNR 值的计算
- 基于MATLAB的音频信号处理技术实现
- matlab、opencv护眼模式之黑色主题
- Matlab Tricks( 八)—— 将 pgm 格式文件转换为 png 格式
- MatLab2012b/MatLab2013b分类器大全(svm,knn,随机森林等)
- utilities(matlab)—— ZCA 白化
- Matlab读取excel数据,并绘图生成exe可执行文件
- matlab 常用 api(七)—— 常见判断(返回 logical)
- 在matlab图像处理中太有用了,regionprops用来度量图像区域属性的函数。
- 如何利用Matlab将.jpg变成logo-将图片白色去掉
- Matlab中regionprops的使用示例
- MATLAB实现图像镜像变换的源代码!
- MATLAB实现图像平移的源代码!
- Matlab Tricks(七)—— 矩阵列/列的归一化/单位化(normalize)
- MATLAB的imtransform()函数作图像线性平移时如果要体现效果要加上目标Size限制!
- Matlab Tricks(六)—— 矩阵乘法的实现
- matlab win7 64bit 找不到vs2013编译器解决办法