Placing Text in a Plot
24 visualizzazioni (ultimi 30 giorni)
I am trying to place some text at upper left corner of my Plot so I used the following code but as there is difference between the data so the text placed is sometimes overlaping, as its using the data to determine the location. So can anyone please sugesst the different way to acheive the same.
Here is the code I used:
text(X_p(imin(1,1)),Y_p(imax),['Average Difference: ',num2str(Avg_Difference_P)]);
text(X_p2(imin2(1,1)),Y_p2(imax2),['Standard Deviation: ',num2str(SD_P)]);
There is also a way using cell but that I am not able to implement properly.
How I can properly place the text?
Più risposte (1)
Stephen23 il 11 Set 2014
Modificato: Stephen23 il 11 Set 2014
MATLAB lets you control all of the text properties , particularly you will want to look at Extent , Position , Units , HorizontalAlignment , VerticalAlignment ,...
- If you want your text to stay in a particular location, regardless of the data, then look at the units and Position properties.
- If you want to adjust how the text is aligned relative to the data, look at Extent.
Keep in mind that this is MATLAB: there is no "intelligent" tool that knows exactly where you want your text to be, you have to calculate that text location yourself. And keep an eye on the units!