How to draw an arrow in Matlab?

前端 未结 5 1295
旧时难觅i
旧时难觅i 2020-11-30 06:00

I\'m trying to draw an arrow in matlab graph, without any success.

Code example:

function [ output_args ] = example( input_args )

figure (\'Name\',          


        
5条回答
  •  粉色の甜心
    2020-11-30 06:21

    You can use arrow from the file exchange. arrow(Start,Stop) draws a line with an arrow from Start to Stop (points should be vectors of length 2 or 3, or matrices with 2 or 3 columns), and returns the graphics handle of the arrow(s).

    Edit: @Lama is also right, you can use annotation but you need to take into account the plot limits.

    annotation('arrow',x,y)
    

    creates an arrow annotation object that extends from the point defined by x(1),y(1) to the point defined by x(2),y(2), specified in normalized figure units. You can use the Data space to figure units conversion function (ds2nfu.m) from the file exchange to make your life easier.

    [xf yf]=ds2nfu(x,y);
    annotation(gcf,'arrow', xf,yf)
    

    enter image description here

    Note that there are some undocumented features that allow pinning annotations to graphs if that is needed, read more about it here...

提交回复
热议问题