How to plot arrow with data coordinates in Matlab?

后端 未结 8 1940
没有蜡笔的小新
没有蜡笔的小新 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:14

    Even though annotation uses normalized as default units, you can associate these objects to the current axes (gca) and use data units for setting X and Y properties.

    Here is an example of plotting a single arrow.

    plot(1:10);
    ha = annotation('arrow');  % store the arrow information in ha
    ha.Parent = gca;           % associate the arrow the the current axes
    ha.X = [5.5 5.5];          % the location in data units
    ha.Y = [2 8];   
    
    ha.LineWidth  = 3;          % make the arrow bolder for the picture
    ha.HeadWidth  = 30;
    ha.HeadLength = 30;
    

提交回复
热议问题