How to plot arrow with data coordinates in Matlab?

后端 未结 8 1930
没有蜡笔的小新
没有蜡笔的小新 2020-12-13 19:37

I know there is a function named annotation can plot arrows or double arrows. But annotation can only plot in normalized unit. For example:

annotation(\'arro         


        
8条回答
  •  感动是毒
    2020-12-13 20:25

    I've just discovered this method, since I don't want to have to bother with normalised units. Use the latex interpreter:

    figure
    plot([1:5],[1:5]*3,'.-')
    %// Say I want to put an arrow pointing to the location, [3 9]    
    text(2.94,8.3,'\uparrow','fontsize',20)
    text(2.8,7.8,'point [3,9]')
    

    To make the arrow longer, use a larger fontsize.

    Pros

    • Easier, faster and quicker than using normalised units
    • Don't need to install any functions (good for us lazy people..)
    • making use of the LaTeX interpreter, there is a whole range of arrows (up, down, left, right and other angles (see Symbol list)

    Cons

    • Definitely needs trial and error/tweaking to get the correct location of the arrow head relative to the POI.
    • There is limited control over the length of the arrow
    • Some latex commands aren't understood by the interpreter (boo).

提交回复
热议问题