bugGNU Octave - Bugs: bug #64929, print() changes legend position

 
 

bug #64929: print() changes legend position

Submitter:  Fabio <efferre79>
Submitted:  Fri 24 Nov 2023 01:16:58 PM UTC
   
 
Category:  Plotting with OpenGL Severity:  3 - Normal
Priority:  5 - Normal Item Group:  Regression
Status:  Patch Submitted Assigned to:  None
Originator Name:  Open/Closed:  * Open
Release:  * 8.4.0 Operating System:  * GNU/Linux
Fixed Release:  None Planned Release:  None
* Mandatory Fields

Add a New Comment Rich Markup
   

Wed 13 Mar 2024 09:41:25 PM UTC, comment #5: 

any news about this?

Fabio <efferre79>
Fri 01 Dec 2023 03:18:31 PM UTC, comment #4: 

I have tested the patch, the figure is now displayed correctly but the output image still shows a shifted legend.

Fabio <efferre79>
Fri 01 Dec 2023 12:38:36 PM UTC, comment #3: 

I attached a patch that improves handling of custom legend position. It fixes the first issue at hand, which is that reducing/restoring the size of the figure changes the legend position.

The second issue, which is the legend shifted in the printout figure, is due to the long standing bug #45600 and the need to scale figures when printing in order to obtain the actual requested fontsize.

(file #55381)

Pantxo Diribarne <pantxo>
Group Member
Sun 26 Nov 2023 08:18:01 PM UTC, comment #2: 

I can confirm the issue. Simply reducing the size of the figure and restoring it (as `print` does in the background) is enough to reproduce:


plot(get(gca,'xlim'),[0.3 0.3],'--r')
lh=legend('peak2peak');
ax=get(gca,'position');
lp = get(lh,'position');
lp = [ax(1)+ax(3)-lp(3) ax(2)+ax(4)-lp(4) lp(3) lp(4)];
set(lh,'position', lp);
fp = get (gcf, 'position');
set (gcf, 'position', [fp(1) fp(2) fp(3)/2 fp(4)/2], 'position', fp);


Pantxo Diribarne <pantxo>
Group Member
Fri 24 Nov 2023 01:21:56 PM UTC, comment #1: 

the problem is there also with other print backends such as .svg so I think it's related to print() reformatting of the figure

Fabio <efferre79>
Fri 24 Nov 2023 01:16:58 PM UTC, original submission:  

I have found the same problem reported in bug #62063 which states it is fixed in 7.1. The example found there is indeed working but instead I can replicate the same kind of problem with the following code


plot(get(gca,'xlim'),[0.3 0.3],'--r')
lh=legend('peak2peak');
ax=get(gca,'position');
lp=get(lh,'position');
set(lh,'position',[ax(1)+ax(3)-lp(3) ax(2)+ax(4)-lp(4) lp(3) lp(4)]);
print('test.png')


The figure shows a shift for the legend after print() execution. The output image shows a shifted legend too.

Tested same problem on Windows.

Fabio <efferre79>

 

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

Attach Files:
   
   
Comment:
   

Attached Files
file #55381:  bug64929.patch added by pantxo (4KiB - text/x-patch)

 

Depends on the following items: None found

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
    2023-12-01 pantxo Attached File- Added bug64929.patch, #55381
        StatusConfirmed Patch Submitted
    2023-11-26 pantxo CategoryPlotting Plotting with OpenGL
        StatusNone Confirmed

    Back to the top

    Powered by Savane 3.13-4b48.
    Corresponding source code