bugGNU Octave - Bugs: bug #65846, multiline title is printed outside...

 
 

bug #65846: multiline title is printed outside image when using inner positionconstraint

Submitter:  Fabio <efferre79>
Submitted:  Fri 07 Jun 2024 02:58:49 PM UTC
   
 
Category:  Plotting with OpenGL Severity:  3 - Normal
Priority:  5 - Normal Item Group:  Incorrect Result
Status:  Confirmed Assigned to:  None
Originator Name:  Open/Closed:  * Open
Release:  * 9.1.0 Operating System:  * Any
Fixed Release:  None Planned Release:  None
* Mandatory Fields

Add a New Comment Rich Markup
   

Jump to the original submission

Mon 10 Jun 2024 11:33:16 AM UTC, comment #6: 


>> Does it make sense?


No, the problem is not related to the output resolution of raster images (actually it will be the same with vector outputs like svg or PDF). On my computer I see no clipping with the code from comment #4. The title is stuck on top of the image though so adding a bit of tolerance would not hurt, e.g.


alpha = get (0, "screenpixelsperinch")/72 * 1.05;


Pantxo Diribarne <pantxo>
Group Member
Mon 10 Jun 2024 09:40:36 AM UTC, comment #5: 

the example code almost solves the problem, there is still a little bit of clipping so more room must be added

it looks like the default printout resolution is 150 so I had changed the line calculating the coefficient to


 alpha = 150 / get (0, "screenpixelsperinch");


Does it make sense?

Fabio <efferre79>
Sun 09 Jun 2024 02:57:38 PM UTC, comment #4: 

Sorry, the example from comment #3 was untested and "labelfontsizemultiplie" should obviously be replaced by "titlefontsizemultiplier":


figure(2)
titlemultiplier = get (0, "defaultaxestitlefontsizemultiplier");
alpha = get (0, "screenpixelsperinch")/72;
plot(1,1)
ht = title(sprintf('first line\nsecond line'))
set(gca,'titlefontsizemultiplier', alpha*titlemultiplier, ...
    'positionconstraint','innerposition', ...
    'titlefontsizemultiplier', titlemultiplier)
print('good.png')


Pantxo Diribarne <pantxo>
Group Member
Sat 08 Jun 2024 09:15:06 AM UTC, comment #3: 

The ratio between the fontsize in printout and onscreen is roughly 1.33 (`get (0, "screenpixelsperinch")/72`) so first writing the title in a larger fontsize, changing the positionconstraint and then setting the fontsize back to the desired printout size should do the job. E.g. :


figure(2)
titlemultiplier = get (0, "defaultaxeslabelfontsizemultiplier");
alpha = get (0, "screenpixelsperinch")/72;
plot(1,1)
ht = title(sprintf('first line\nsecond line'))
set(gca,'labelfontsizemultiplier', alpha*titlemultiplier, ...
    'positionconstraint','innerposition', ...
    'labelfontsizemultiplier', titlemultiplier)
print('good.png')


Pantxo Diribarne <pantxo>
Group Member
Fri 07 Jun 2024 03:41:58 PM UTC, comment #2: 

in which way I can add more room for the title?

BTW I am under Linux and not Windows

Fabio <efferre79>
Fri 07 Jun 2024 03:31:55 PM UTC, comment #1: 

This is another consequence of bug #45600 : printout fonts are larger than onscreen and thus titles that fit in the available space onscreen, may be too large in printout.

The workaround, until bug #45600 is fixed, is to leave more room for the multiline titles.

Pantxo Diribarne <pantxo>
Group Member
Fri 07 Jun 2024 02:58:49 PM UTC, original submission:  

I have a script that produces many output images from many plot kinds (plotyy, plot with subplots, etc). I am trying to align horizontally the plots by setting the first and third element of the "position" axis property. I do other customizations such as change of the fontsize, for this reason I need to force "positionconstraint" to innerposition too.

The plots look fine in the figures while print() produces an output image that has a portion of the title text clipped when using multiline. The minimum code snippet shows the difference in the result:


figure(1)
plot(1,1)
title(sprintf('first line\nsecond line'))
set(gca,'positionconstraint','innerposition')
print('bad.png')

figure(2)
plot(1,1)
title(sprintf('first line\nsecond line'))
set(gca,'positionconstraint','outerposition')  % not needed
print('good.png')


No annotation is added after the set() call so all the graphic elements should have a defined position. If I invert the set() and title() calls the result is the same, of course in that case the dimensions and position of the plots would be slightly different.

With print() I expect to have the same result visible in the figure.

Fabio <efferre79>

 

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

Attach Files:
   
   
Comment:
   

No files currently attached

 

Digest:
   bug dependencies.

Items that depend on this one: None found

 

Carbon-Copy List
  • -email is unavailable- added by pantxo (Posted a comment)
  • -email is unavailable- added by efferre79 (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.

     

    Follow 4 latest changes.

    Date Changed by Updated Field Previous Value => Replaced by
    2024-06-07 pantxo CategoryPlotting Plotting with OpenGL
        StatusNone Confirmed
        Operating SystemGNU/Linux Any
        Dependencies- Depends on bugs #45600

    Back to the top

    Powered by Savane 3.14-f13d.
    Corresponding source code