bugGNU Octave - Bugs: bug #55019, new sgtitle function

 
 

bug #55019: new sgtitle function

Submitter:  Marshall <marsian>
Submitted:  Tue 13 Nov 2018 09:47:41 PM UTC
   
 
Category:  Plotting Severity:  3 - Normal
Priority:  5 - Normal Item Group:  Feature Request
Status:  None Assigned to:  None
Originator Name:  Marsian Open/Closed:  * Open
Release:  * dev Operating System:  * Any
Fixed Release:  None Planned Release:  None
* Mandatory Fields

Add a New Comment Rich Markup
   

Jump to the original submission

Thu 28 Oct 2021 05:15:14 PM UTC, comment #8: 

comment #7:

> I just answered a question on stackoverflow which referred to this bugreport (here: https://stackoverflow.com/a/67174926/4183191 ) where I had pointed out that a 'main window' title is simply a title in an empty 'main' axes object, i.e.
>


> axes( 'visible', 'off', 'title', 'This is the main title' );


>
> I was pretty sure that this is the obvious way to add a main title, but seeing the comments here suggest alternatives, now I'm not so sure. Perhaps a bespoke sgtitle function might be a good idea after all...
>


This is the only solution reported here that works, thanks!

Fabio <efferre79>
Tue 20 Apr 2021 08:28:48 AM UTC, comment #7: 

I just answered a question on stackoverflow which referred to this bugreport (here: https://stackoverflow.com/a/67174926/4183191 ) where I had pointed out that a 'main window' title is simply a title in an empty 'main' axes object, i.e.


axes( 'visible', 'off', 'title', 'This is the main title' );


I was pretty sure that this is the obvious way to add a main title, but seeing the comments here suggest alternatives, now I'm not so sure. Perhaps a bespoke sgtitle function might be a good idea after all...

Tasos Papastylianou <tpapastylianou>
Fri 30 Nov 2018 11:21:46 PM UTC, comment #6: 

Comment #5 gives a decent work around, though I agree that it is not perfect. It took me a bit to figure out that text position attached to a figure is from -1 to 1 in x and y instead of 0 to 1, as is used to position axes (at least before an axis is placed).


ht = text(0,0.98,'sgtitle text','parent',gcf,'horizontalalignment','center','verticalalignment','top');

The above places it at the top of a blank figure.

However, if I place this text before a subplot (e.g. subplot(5,5,3)), then the text moves position as soon as the subplot is created: relative to the axes position now (in data units of the placed axis). Text placed after an axes is created, then even with the figure as parent it is positioned relative to the data units of the last axes.

Marshall <marsian>
Thu 15 Nov 2018 12:06:53 AM UTC, comment #5: 

It's not perfect, but you can create a text object that is attached to the figure and then move it around by changing the 'position' property.


>> hf = figure
hf =  1
>> ht = text (0,0, 'sgtitle text', 'parent', hf)
ht = -24.157
>> set (ht, 'position', [0 0.5 0])



Rik <rik5>
Group administrator
Wed 14 Nov 2018 05:16:17 PM UTC, comment #4: 

The parent of the sgtitle text is the figure. The parent of the standard title is the axes object. The parents of each of the subplot axes objects are also the figure.

Marshall <marsian>
Wed 14 Nov 2018 03:34:54 PM UTC, comment #3: 

@Marsian: If you have access to Matlab 2018b it would be useful to know who's child the text object.is. Is it the axes that were current when creating the sgtitle text?

Pantxo Diribarne <pantxo>
Group Member
Wed 14 Nov 2018 12:26:41 AM UTC, comment #2: 

It's a little more than just placing a single text object correctly. It also changes existing and new subplot sizes to give room for that text object so that it doesn't interfere with other titles or subplots.

Marshall <marsian>
Tue 13 Nov 2018 10:13:40 PM UTC, comment #1: 

Looking at the documentation, sgtitle just creates a text object and then places it correctly.  This shouldn't be that hard to do in an m-file.  If anyone wants to take a stab at creating the function I can review and commit it.

Rik <rik5>
Group administrator
Tue 13 Nov 2018 09:47:41 PM UTC, original submission:  

As of 2018b, Matlab has a new function, 'sgtitle'. It would be nice if Octave had it too. It creates a single title centered at the top of the figure for a plot window with subplots, which could have their own separate titles via 'title'. A very handy function that I've had to do some odd workarounds to get similar functionality in the past.

Marshall <marsian>

 

(Note: upload size limit is set to 16384 kB, after insertion of the required escape characters.)

Attach Files:
   
   
Comment:
   

No files currently attached

 

Depends on the following items: None found

Items that depend on this one: None found

 

Carbon-Copy List
  • -email is unavailable- added by efferre79 (Posted a comment)
  • -email is unavailable- added by tpapastylianou (Posted a comment)
  • -email is unavailable- added by pantxo (Posted a comment)
  • -email is unavailable- added by rik5 (Posted a comment)
  • -email is unavailable- added by marsian (Submitted the item)
  •  

    There are 0 votes so far. Votes easily highlight which items people would like to see resolved in priority, independently of the priority of the item set by tracker managers.

    Only group members can vote.

     

    Follows 1 latest change.

    Date Changed by Updated Field Previous Value => Replaced by
    2018-11-13 rik5 Release4.4.1 dev

    Back to the top

    Powered by Savane 3.13-f8d8.
    Corresponding source code