`text` or `annotation` with coordinate positions

classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

`text` or `annotation` with coordinate positions

Octave - General mailing list
Hi,

is it possible to use plot annotations positioned like that?

     annotation ('textbox', 'southeast', 'string', 'hello world')
     text('textbox', 'location', 'southeast', 'string', 'hello world')

Those commands do not work, but i think you see what i mean
(wanna use coordinate locations).

It adds too much code to extract the values of `axis` and calculate
the proper positions for my text.

Thx


Reply | Threaded
Open this post in threaded view
|

Re: `text` or `annotation` with coordinate positions

nrjank
On Tue, Dec 17, 2019 at 8:33 AM oxy via Help list for GNU Octave <[hidden email]> wrote:
Hi,

is it possible to use plot annotations positioned like that?

     annotation ('textbox', 'southeast', 'string', 'hello world')
     text('textbox', 'location', 'southeast', 'string', 'hello world')

Those commands do not work, but i think you see what i mean
(wanna use coordinate locations).

It adds too much code to extract the values of `axis` and calculate
the proper positions for my text.

 
the position names "north", "south", etc., I believe are limited in use to legend objects, where it is specified as a name/value pair, eg., "location", "northeast".  
see:

looking at the help text for both text and annotation:

they require specified coordinate positions. 

Checking for compatibility, it appears that the behavior is the same in Matlab.  if you have ideas for extending those functions to provide additional capability without breaking compatibility, feel free to share with the group, although since the code to extract and calculate positions not overly complicated, priority might be low.


Reply | Threaded
Open this post in threaded view
|

Re: `text` or `annotation` with coordinate positions

Octave - General mailing list

On Dec 17, 2019, at 07:50, Nicholas Jankowski <[hidden email]> wrote:

On Tue, Dec 17, 2019 at 8:33 AM oxy via Help list for GNU Octave <[hidden email]> wrote:
Hi,

is it possible to use plot annotations positioned like that?

     annotation ('textbox', 'southeast', 'string', 'hello world')
     text('textbox', 'location', 'southeast', 'string', 'hello world')

Those commands do not work, but i think you see what i mean
(wanna use coordinate locations).

It adds too much code to extract the values of `axis` and calculate
the proper positions for my text.

 
the position names "north", "south", etc., I believe are limited in use to legend objects, where it is specified as a name/value pair, eg., "location", "northeast".  
see:

looking at the help text for both text and annotation:

they require specified coordinate positions. 

Checking for compatibility, it appears that the behavior is the same in Matlab.  if you have ideas for extending those functions to provide additional capability without breaking compatibility, feel free to share with the group, although since the code to extract and calculate positions not overly complicated, priority might be low.

Have you considered changing the text object‘s ”units” to “normalized” and appropriately modifying the ”horizontalalignment” and “verticalalignment” properties?

Ben



Reply | Threaded
Open this post in threaded view
|

Re: `text` or `annotation` with coordinate positions

BGreen

On Tue, Dec 17, 2019 at 11:07 AM Ben Abbott via Help list for GNU Octave <[hidden email]> wrote:

On Dec 17, 2019, at 07:50, Nicholas Jankowski <[hidden email]> wrote:

On Tue, Dec 17, 2019 at 8:33 AM oxy via Help list for GNU Octave <[hidden email]> wrote:
Hi,

is it possible to use plot annotations positioned like that?

     annotation ('textbox', 'southeast', 'string', 'hello world')
     text('textbox', 'location', 'southeast', 'string', 'hello world')

Those commands do not work, but i think you see what i mean
(wanna use coordinate locations).

It adds too much code to extract the values of `axis` and calculate
the proper positions for my text.

 
the position names "north", "south", etc., I believe are limited in use to legend objects, where it is specified as a name/value pair, eg., "location", "northeast".  
see:

looking at the help text for both text and annotation:

they require specified coordinate positions. 

Checking for compatibility, it appears that the behavior is the same in Matlab.  if you have ideas for extending those functions to provide additional capability without breaking compatibility, feel free to share with the group, although since the code to extract and calculate positions not overly complicated, priority might be low.

Have you considered changing the text object‘s ”units” to “normalized” and appropriately modifying the ”horizontalalignment” and “verticalalignment” properties?

Ben


For what it's worth, if I had to decide between the directional commands (e.g. "southeast") and the numerical position, I much prefer to have fine manual control through the latter. Having both available would be the ideal solution.

An alternative is to write a script that generates position vectors from the current axes - for example, rather than calling
lg = legend("Test text","location","southeast")
one might call
[northeast,southeast,...] = location_generator(gca);
lg = legend("Test text","position",southeast)

In oxy's example, this position vector could then be used for other things like annotations as well.

Actually, that gives me an idea: here's an awkward way to do things that might accomplish what you want by harvesting the position value from a temporary legend:

lg=legend("Filler text","location","southeast");
lgpos = get(lg,"position");
delete(lg);
annotation("textbox",lgpos,"string","Text here");