From: Assaf Weinstein on
Hi,

I want to add a texbox to an existing figure (in code, not by tool) at a specified point (x,y). I try using

annotation('textbox',[x, y, .1, .1],'FitBoxToText','on')

but x,y need to be in normalized figure form, so I want to use ds2nfu(x,y), but in this function, x and y each specify a point (not x and y values..), and im not sure what to do..

What is the simplest way to (programatically) add a texbox to an existing figure at a specified point (x,y)?

thanks!

Asaf
From: us on
"Assaf Weinstein" <assafweinstein_remove.this(a)gmail.com> wrote in message <i0sn5v$jfh$1(a)fred.mathworks.com>...
> Hi,
>
> I want to add a texbox to an existing figure (in code, not by tool) at a specified point (x,y). I try using
>
> annotation('textbox',[x, y, .1, .1],'FitBoxToText','on')
>
> but x,y need to be in normalized figure form, so I want to use ds2nfu(x,y), but in this function, x and y each specify a point (not x and y values..), and im not sure what to do..
>
> What is the simplest way to (programatically) add a texbox to an existing figure at a specified point (x,y)?
>
> thanks!
>
> Asaf

one of the solutions

line(1:10,1:10);
ah=annotation('textbox');
% note: the position is set with respect to AH's own AXIS(!)...
set(ah,'position',[.4,.2,.4,.3]);
% - make the parent axis visible...
disp('cont with any key...');
pause;
ap=get(ah,'parent'); % <- is NOT GCA(!)...
set(ap,'visible','on');

us
From: Assaf Weinstein on
"us " <us(a)neurol.unizh.ch> wrote in message <i0t20r$3d$1(a)fred.mathworks.com>...
> "Assaf Weinstein" <assafweinstein_remove.this(a)gmail.com> wrote in message <i0sn5v$jfh$1(a)fred.mathworks.com>...
> > Hi,
> >
> > I want to add a texbox to an existing figure (in code, not by tool) at a specified point (x,y). I try using
> >
> > annotation('textbox',[x, y, .1, .1],'FitBoxToText','on')
> >
> > but x,y need to be in normalized figure form, so I want to use ds2nfu(x,y), but in this function, x and y each specify a point (not x and y values..), and im not sure what to do..
> >
> > What is the simplest way to (programatically) add a texbox to an existing figure at a specified point (x,y)?
> >
> > thanks!
> >
> > Asaf
>
> one of the solutions
>
> line(1:10,1:10);
> ah=annotation('textbox');
> % note: the position is set with respect to AH's own AXIS(!)...
> set(ah,'position',[.4,.2,.4,.3]);
> % - make the parent axis visible...
> disp('cont with any key...');
> pause;
> ap=get(ah,'parent'); % <- is NOT GCA(!)...
> set(ap,'visible','on');
>
> us


Thanks so much for this; Im sorry, but I don't understand what the following part is meant for

> % - make the parent axis visible...
> disp('cont with any key...');
> pause;
> ap=get(ah,'parent'); % <- is NOT GCA(!)...
> set(ap,'visible','on');

and also, I feel that I don't get what you mean exactly with the ANNOTATION's own axis (vs whose? GCA's?...)

Last thing - I origianlly looked to specify the textbox's position with data points values (rather than normalized figure values..).

Thank you again,

Asaf