Matlab中绘制带箭头的坐标轴

转载自:http://blog.sina.com.cn/s/blog_6427cceb0100xnj9.html

方法一:

============================================================================

下面的程序虽然显示带箭头的坐标轴,但事实上并非真正的坐标轴,而是使用fill函数在两个直线段的终点填充了一个三角面而已。

Matlab 代码:

x=-5:10;
y=-5:10;
plot([0 0],[min(y),max(y)],'k',[min(x),max(x)],[0 0],'k');
axis off
hold on
ax=[max(x),max(x)-0.3,max(x)-0.3;0,0.2,-0.2];
fill(ax(1,:),ax(2,:),'k');
ay=[0,0.15,-0.15;max(y),max(y)-0.4,max(y)-0.4];
fill(ay(1,:),ay(2,:),'k');

方法二:

===========================================================================

Matlab代码:

x1=linspace(0,1,100);
y1=x1.^2;
figure1 = figure('PaperPosition',[0.6345 6.345 20.315.23],'PaperSize',[20.98 29.68]);
axes1 = axes('Parent',figure1);
hold(axes1,'all');
plot1 = plot(x1,y1);
annotation1 = annotation(figure1,'arrow',[0.131 0.131],[0.920.96]);
annotation2 = annotation(figure1,'arrow',[0.88 0.96],[0.1080.108]);

相关参数说明:

=====================================================================

PaperPosition

four-element rect vector

Location on printed page. Arectangle that determines the location of the figure on the printed page.Specify this rectangle with a vector of the form

     rect = [left,bottom, width, height]

     where left specifies the distance from theleft side of the paper to the left side of the rectangle and bottom specifiesthe distance from the bottom of the page to the bottom of the rectangle.Together these distances define the lower-left corner of the rectangle. widthand height define the dimensions of the rectangle. The PaperUnits propertyspecifies the units used to define this rectangle.

也就是说PaperPosition是在打印页面上的位置

This example exports a figure at screen size to a 24-bitTIFF file, myfigure.tif.

set(gcf, 'PaperPositionMode', 'auto')   % Use screen size

print -dtiff myfigure

 

 PaperSize

PaperSize 向量[width,height]代表了用于打印的纸张尺寸,单位由PaperUnits属性指定

papersize是纸张大小;position要比size小的

 

axes1 = axes('Parent',figure1);

是指定figure1为axes1的父对象,所以axes1将会在figure1中显示出来。如果你不指定父对象,MATLAB就会自动把“当前figure”作为axes1的父对象。

 

If you want to make an axes the current axes withoutchanging the state of the parent figure, set the CurrentAxes property of thefigure containing the axes:

set(figure_handle,'CurrentAxes',axes_handle)

This command is useful if you want a figure to remainminimized or stacked below other figures, but want to specify the current axes

 

ANNOTATION creates an annotation object

    ANNOTATION(ANNOTATIONTYPE)creates a default annotation of type

    ANNOTATIONTYPE inthe current figure.  ANNOTATIONTYPE maybe one of the following:

        'rectangle'

        'ellipse'

        'textbox'

        'line'

        'arrow'

        'doublearrow'= two headed arrow

        'textarrow' =arrow with text at tail end

ANNOTATION('arrow',X,Y) creates an arrow annotation withendpoints specified in normalized figure coordinates by the vectors X and Y.

X(1) and Y(1) specify the position of the tail end of thearrow and X(2) and Y(2) specify the position at the tip of the arrow head.

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值