Matlab绘制自然原点坐标的坐标轴
2014-06-09 22:06
573 查看
standard_axes函数, 可以将函数的坐标轴按照自然原点坐标显示
>> hAxes1=axes('Position', [0.13,0.58,0.77,0.34]);
>> T = linspace(-2*pi,2*pi,10);
>> h = stem(T,cos(T),'fill','--');
>> set(get(h,'BaseLine'),'LineStyle',':');
>> set(h,'MarkerFaceColor','red');
>> standard_axes(hAxes1)
>> hAxes2=axes('Position', [0.13,0.11,0.33,0.34]);
>> t=0:0.01:2*pi;
>> x=5*(2*cos(t)-cos(2*t));
>> y=5*(2*sin(t)-sin(2*t));
>> plot(x,y);
>> standard_axes(hAxes2)
>> hAxes3=axes('Position', [0.57,0.11,0.33,0.34]);
>> hz=[20:10:100,200:100:1000,1500,2000:1000:10000];
>> spl =[76,66,59,54,49,46,43,40,38,22,14,9,6,3.5,2.5,1.4,0.7,0,-1,-3,-8,-7,-2,2,7,9,11,12];
>> semilogx(hz,spl,'k-o');
>> standard_axes(hAxes3)
====================================================== function varargout = standard_axes(axes_handle) % STANDARD_AXES 创建标准坐标系 % STANDARD_AXES 将当前坐标系转换为标准坐标系 % STANDARD_AXES(H) 将由H指定的坐标系转换为标准坐标系 % AX = STANDARD_AXES(...) 返回转换后的标准坐标系的横轴和纵轴的句柄向量 % [AX1,AX2] = STANDARD_AXES(...) 返回转换后的标准坐标系的横轴句柄和纵轴句柄 % 输入参数: % ---H,指定的坐标轴句柄 % 输出参数: % ---AX,AX1,AX2, 标准坐标系的横轴和纵轴句柄 % % See also axes, annotation if nargin == 0 axes_handle = gca; end pos = get(axes_handle,'Position'); x_Lim = get(axes_handle,'Xlim'); y_Lim = get(axes_handle,'Ylim'); x_Scale = get(axes_handle,'XScale'); y_Scale = get(axes_handle,'YScale'); color = get(gcf,'Color'); if prod(y_Lim)>0 position_x = [pos(1), pos(2)+pos(4)/2, pos(3), eps]; else position_x = [pos(1), pos(2)-y_Lim(1)/diff(y_Lim)*pos(4), pos(3), eps]; end axes_x = axes('Position', position_x,'Xlim',x_Lim,'Color',color,... 'XScale',x_Scale,'YScale',y_Scale); if prod(x_Lim)>0 position_y = [pos(1)+pos(3)/2, pos(2), eps, pos(4)]; else position_y = [pos(1)-x_Lim(1)/diff(x_Lim)*pos(3), pos(2), eps, pos(4)]; end axes_y = axes('Position', position_y, 'Ylim', y_Lim, 'Color', color, ... 'XScale', x_Scale, 'YScale', y_Scale); set(axes_handle, 'Visible', 'off') annotation('arrow', [pos(1)-0.065*pos(3), pos(1)+pos(3)+0.065*pos(3)], ... [position_x(2)-0.001,position_x(2)-0.001],'HeadLength',6,'HeadWidth',6); annotation('arrow', [position_y(1)+0.001, position_y(1)+0.001],... [pos(2)-0.065*pos(4),pos(2)+pos(4)+0.065*pos(4)],... 'HeadLength',6,'HeadWidth',6); if nargout == 1 varargout{1} = [axes_x,axes_y]; elseif nargout == 2 varargout{1} = axes_x; varargout{2} = axes_y; elseif nargout > 2 error('Too many output arguments.'); end
==========================================================
>> hAxes1=axes('Position', [0.13,0.58,0.77,0.34]);
>> T = linspace(-2*pi,2*pi,10);
>> h = stem(T,cos(T),'fill','--');
>> set(get(h,'BaseLine'),'LineStyle',':');
>> set(h,'MarkerFaceColor','red');
>> standard_axes(hAxes1)
>> hAxes2=axes('Position', [0.13,0.11,0.33,0.34]);
>> t=0:0.01:2*pi;
>> x=5*(2*cos(t)-cos(2*t));
>> y=5*(2*sin(t)-sin(2*t));
>> plot(x,y);
>> standard_axes(hAxes2)
>> hAxes3=axes('Position', [0.57,0.11,0.33,0.34]);
>> hz=[20:10:100,200:100:1000,1500,2000:1000:10000];
>> spl =[76,66,59,54,49,46,43,40,38,22,14,9,6,3.5,2.5,1.4,0.7,0,-1,-3,-8,-7,-2,2,7,9,11,12];
>> semilogx(hz,spl,'k-o');
>> standard_axes(hAxes3)
相关文章推荐
- matlab中绘制平行于坐标轴的直线
- MATLAB 把坐标轴(X Y轴)移到坐标原点
- 在Matlab中根据离散点坐标绘制空间曲面
- Matlab绘制图像后在指定点绘制坐标线以及标注变量
- MATLAB 根据X、Y坐标绘制折线图,增加右侧纵轴刻度且不用plotyy
- Matlab中绘制带箭头的坐标轴
- matlab画图:绘制双图,上图以条形图(分割开来的两根bar),下图是残差。。。横坐标为日期
- Matlab手动绘制bounding box,并获取其坐标
- MATLAB绘图基础02-双坐标轴绘制
- 在matlab中寻找曲线上离原点距离最近的点的坐标的思考
- MATLAB中绘制图形的时候,坐标和标题倒置
- html5绘制变形图形-变换坐标原点
- MATLAB绘制双坐标图
- f(x)*(-1)^x的离散傅里叶变换及Matlab中如何绘制坐标轴
- matlab绘制曲面并标注坐标轴
- Matlab绘制带箭头坐标
- 在Matlab中根据离散点坐标绘制空间曲面
- 白鹭引擎 - 显示对象的基准点与横纵坐标 ( 绘制一个来回移动的绿色方块 )
- 平面上有一点(x,y),将其绕坐标原点旋转一角度α,求旋转后的点的坐标
- 使用多边形绘制图像(MATLAB)