peaks;
axis tight  %Set the axis limits to equal the range of the data 
axis square
axis 'auto x'  %x轴坐标上下限自动调整
axis off    %Plot a surface without displaying the axes lines and background.
set(gca,'Visible','off');   %消除坐标轴,显示范围的大小没有改变,同上句
    %更多特性可参考帮助
%同时设置subplot的多幅图像的axis
%Create a figure with two subplots.set the axis limits for the subplots to the same values.
x1 = linspace(0,10,100);y1 = sin(x1);
ax1 = subplot(2,1,1);plot(ax1,x1,y1)
x2 = linspace(0,5,100);y2 = sin(x2);
ax2 = subplot(2,1,2);plot(ax2,x2,y2);
 
axis([ax1 ax2],[0 10 -1 1])
%如果想在原图上继续作图,而不改变原坐标系的区间
x = linspace(0,10);y = sin(x);plot(x,y)
y2 = 2*sin(x);hold on
axis manual    %关键步骤,冻结axis 可以对比不加该语句的结果
plot(x,y2);hold off
%改变坐标系的方向(指向)
C = eye(10);
pcolor(C)
colormap summer
%Reverse the coordinate system so that the y values increase from top to bottom.
axis ij;   %第i行,第j列
%上下两条语句等价
set(gca,'Ydir','reverse');  

应用举例:自动调整x,y的区间,并移动坐标原点

set(groot,'defaultAxesLineStyleOrder','remove','defaultAxesColorOrder','remove');
    %每次使用记得清除上次设置的参数,否则设置的参数会被保留下来
x=1:255;y=rand(1,255);y=y';%y是行向量还是列向量都无所谓
n=length(x);
stem(x,y, 'Marker', 'none');  
title('未设置坐标轴的区间'); 

%坐标轴区间的自动设置(适用于直方图的显示)
% Get x/y limits of axes using axis
hist_axes = gca;
limits = axis(hist_axes);
if n ~= 1  %当只有一个值时设置x坐标轴
  limits(1) = min(x);
else
  limits(1) = 0;
end
limits(2) = max(x);
var = sqrt(y'*y/length(y));
limits(4) = 2.5*var;   %只改变了y轴显示的高度
axis(hist_axes,limits);
title('设置了的坐标轴区间'); 

%改变图像的坐标原点(本应属于该节内容)
% In GUIDE, default axes units are characters. In order for axes repositiong
% to behave properly, units need to be normalized.
hist_axes_units_old = get(hist_axes,'units');
set(hist_axes,'Units','Normalized');
%Get axis position and make room for others.
pos = get(hist_axes,'pos');
stripe = 0.2;
set(hist_axes,'pos',[pos(1) pos(2)+stripe*pos(4) pos(3) (1-stripe)*pos(4)])
set(hist_axes,'Units',hist_axes_units_old);  %坐标向上移动了,相应也调整了整个图众向比例
title('移动了的坐标原点'); 
 
 
 
 

Matlab绘图基础——axis设置坐标轴取值范围的更多相关文章

  1. Matlab绘图基础——利用axes(坐标系图形对象)绘制重叠图像 及 一图多轴(一幅图绘制多个坐标轴)

    描述 axes在当前窗口中创建一个包含默认属性坐标系 axes('PropertyName',propertyvalue,...)创建坐标系时,同时指定它的一些属性,没有指定的使用DefaultAxe ...

  2. Matlab绘图基础——图形修饰处理(入门)

    引入--标题.色条.坐标轴.图例等 例一: set(groot,'defaultAxesLineStyleOrder','remove','defaultAxesColorOrder','remove ...

  3. js localStorage 设置和取值

    定义 Storage 对象,对象有get(取值), set(设置), add(加入新值)三个方法 const Storage = {} Storage.get = function (name) { ...

  4. Matlab绘图基础——一些标准三维曲面

    标准三维曲面 t=0:pi/20:2*pi; [x,y,z]= cylinder(2+sin(t),30);     %[x,y,z]= cylinder(R,n),其中R为圆周半径,n为组成圆周的点 ...

  5. web.config设置和取值

    博客园中有一篇文章对web.config的结构做了很详细的介绍,原文见 http://www.cnblogs.com/gaoweipeng/archive/2009/05/17/1458762.htm ...

  6. jquery对strutrs2 <s:radio>标签的设置和取值

    今天郁闷了1小时. 需求是这样的: <s:radio  list="#{0:'男',1:'女'}" value="member.sex" id=" ...

  7. Matlab绘图基础——绘制三维表面

    %绘制三维表面 ------------------------------------- %1.绘制线框图:mesh:每一条曲线称为mesh line %首先利用meshgrid函数产生平面区域内的 ...

  8. matlab绘图基础

    matlab绘制条形图并分组显示: a =[1 2 3] b =[4 5 6] >> d=[a;b] d = 1 2 3 4 5 6 >> bar(d,'group') 修改横 ...

  9. Matlab绘图基础——用print函数保存图片(Print figure or save to file)

    print(figure_handle,'formats','-rnumber','filename')  %将图形保存为png格式,分辨率为number的(默认为72),最好指定的分辨率大一点,否则 ...

随机推荐

  1. WebService之CXF注解之五(配置文件)

    1.web.xml <?xml version="1.0" encoding="UTF-8"?> <web-app version=" ...

  2. (二十八)monggodb和maven零散笔记

    (1)maven导包的问题:当在pom.xml界面的Dependencies中点击add之后输入jar包查询条件后,如果确定条件没有输错,repo中也确实存在相关jar包,而并没有查处任何结果时,可以 ...

  3. Vxworks下的SATA提速

    1.       ATA接口的三种数据传输方式 (1)PIO(Programmable Input-Output)传输,可以分为PIO寄存器传输和PIO数据传输.PIO寄存器传输主要用于对ATA设备中 ...

  4. VxWorks6.6 pcPentium BSP 使用说明(一):基本概念

    "VxWorks6.6 BSP 使用说明"将发布pcPentium和idp945两个系列的BSP的使用说明.每个系列约5篇文章.之后还将发布由这两个官方提供的BSP的实战移植方法. ...

  5. Linux显示计算次数的结果

    Linux显示计算次数的结果 youhaidong@youhaidong-ThinkPad-Edge-E545:~$ free -c free:选项需要一个参数 -- c Usage: free [o ...

  6. 小白进阶之Scrapy(基于Scrapy-Redis的分布式以及cookies池)

    首先我们更新一下scrapy版本.最新版为1.3 再说一遍Windows的小伙伴儿 pip是装不上Scrapy的.推荐使用anaconda .不然还是老老实实用Linux吧. conda instal ...

  7. pat1121-1131

    1121 #include<cmath> #include<map> #include<iostream> #include<cstring> #inc ...

  8. pat1091-1100

    1091bfs傻逼题,dfs会爆栈 #include<iostream> #include<cstdio> #include<cstring> #include&l ...

  9. Vue安装依赖npm install时报错问题解决方法

    1.vue的安装依赖于node.js,要确保你的计算机上已安装过node.js.    可进入cmd编辑器,输入命令 node -v进行查看.出现版本信息即成功!没有则从浏览器上面下载安装即可,没有安 ...

  10. 【BZOJ1189】紧急疏散(二分答案,最大流)

    [BZOJ1189]紧急疏散(二分答案,最大流) 题面 Description 发生了火警,所有人员需要紧急疏散!假设每个房间是一个N M的矩形区域.每个格子如果是'.',那么表示这是一块空地:如果是 ...