Annotation position driving me mad!! changing the position values won't work...
3 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
I have a position for my annotation on an axis, but it keeps being placed in another location and changing the position values doesn't seem to work!! can someone help me?
code:
axes5 = axes('Parent',gcf,'FontSize',16,...
'Position',[0.727083333333333 0.10948905109489 0.227777777777778 0.352189781021897]);
hold(axes5,'on');
h = annotation(gcf,'textbox',...
[0.887210317460318 0.0666889185580782 0.0746944444444443 0.148331108144192],...
'LineStyle','none',...
'FitBoxToText','off','position',[0.652488095238095 0.153471295060081 0.0746944444444444 0.148331108144192],'String',...
{['mixture of strings and mat2str functions used here to display fit coefficients, r^2 etc.']});
cheers! Michael
0 comentarios
Respuestas (2)
Image Analyst
el 6 de Nov. de 2015
Your 'Units' property is probably wrong - not 'normalized'. Try specifying normalized units
axes(....... , 'Units', 'normalized', ................);
0 comentarios
Mike Garrity
el 6 de Nov. de 2015
What did you expect this to do? And how does that differ from what it is doing?
Here's a simplified version of your code:
p1 = [0.727083333333333 0.10948905109489 ...
0.227777777777778 0.352189781021897];
axes5 = axes('Parent',gcf,'FontSize',16,...
'Position',p1);
p2 = [0.887210317460318 0.0666889185580782 ...
0.0746944444444443 0.148331108144192];
p3 = [0.652488095238095 0.153471295060081 ...
0.0746944444444444 0.148331108144192];
h = annotation(gcf,'textbox',p2,...
'LineStyle','none',...
'FitBoxToText','off','Position',p3, ...
'String',['mixture of strings and mat2str functions' ...
' used here to display fit coefficients, r^2 etc.']);
We can label the X coordinates like so:
annotation('textarrow',[p1(1) p1(1)],[.70 .3],'String',sprintf('X = %g',p1(1)))
annotation('textarrow',[p2(1) p2(1)],[.75 .3],'String',sprintf('X = %g',p2(1)))
annotation('textarrow',[p3(1) p3(1)],[.80 .3],'String',sprintf('X = %g',p3(1)))
And we get this:
As you can see, the left side of the axes is at p1(1), which is what you specified. The left side of the text box is at p3(1). This one's a little tricky because you gave the annotation command two different positions. The first one (p2) was passed in as the 3rd argument. The second one (p3) was passed in using "PV-pairs". In this case, the second one wins. If you had specified the Position several times in the PV-pairs, then the last one would have one.
You can do the same sort of operation for the other 3 components of the Position, and I think that you'll find that it is doing what you asked it to do.
0 comentarios
Ver también
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!