How to plot arrow with data coordinates in Matlab?

datcn picture datcn · Jul 16, 2012 · Viewed 68.6k times · Source

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('arrows',[x1 x2],[y1 y2])

Here, [x1, x2] should be a ratio number less than one.

So, my question is how can I plot arrows with a true value rather than a normalized value?

I wonder if there is any other function can approach this or is there any function I can get the axis value of the figure so that I can adjust the true value into a normalized value.

Answer

H.Muster picture H.Muster · Jul 16, 2012

For the positioning of annotations, Matlab offers the function dsxy2figxy to convert data space points to normalized space coordinates. However, for whatever reasons, the function is not included in the Matlab distribution and has to be "created" first.

Copy the following line into the command window and execute it to open the function in your editor.

edit(fullfile(docroot,'techdoc','creating_plots','examples','dsxy2figxy.m'))

To use the function dsxy2figxy save it somewhere in your matlab search path.

Please find the full instructions for the function dsxy2figxy at matlab-central: http://www.mathworks.de/help/techdoc/creating_plots/bquk5ia-1.html