plot annotation without normalizing
14 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Hello,
I am trying to position my annotation arrows onto a 2D XY plot but it seems that annotation x and y points can only be in normalized units. I would like to place my annotation arrows using the X and Y values that I used for plotting the data. Can someone please help me to convert the data values to normalized values? I have gone through a whole bunch of posts in Matlab and stack overflow but nothing is working. The below code should have worked but it didn't.
"
First, you need to find the position of the axes in normalized figure units. Fortunately, they're set to 'normalized' by default.
axPos = get(gca,'Position'); %# gca gets the handle to the current axes axPos is [xMin,yMin,xExtent,yExtent]
Then, you get the limits, i.e. min and max of the axes.
xMinMax = xlim; yMinMax = ylim; Finally, you can calculate the annotation x and y from the plot x and y.
xAnnotation = axPos(1) + ((xPlot - xMinMax(1))/(xMinMax(2)-xMinMax(1))) * axPos(3); yAnnotation = axPos(2) + ((yPlot - yMinMax(1))/(yMinMax(2)-yMinMax(1))) * axPos(4); Use xAnnotation and yAnnotation as x and y coordinates for your annotation."
So, from this code I understand that "xPlot" and "yPlot" are supposed to represent the databvalues from your plot that you want to convert to normalized unit. However, when I replace the "xPlot" and "yPlot" with specific data value from my plot such as 100 and 200 respectively then my yAnnotation gives a value of 18 and xAnnotation gives a value of 5.3 which is not within the range of 0 to 1!!!!
Can someone please please help me!! Many thanks
0 Kommentare
Antworten (1)
Walter Roberson
am 1 Apr. 2018
https://www.mathworks.com/matlabcentral/fileexchange/63760-annotate
1 Kommentar
Siehe auch
Kategorien
Mehr zu Annotations finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!