bugGNU Octave - Bugs: bug #60759, test subplot fails on hi-res...

 
 

bug #60759: test subplot fails on hi-res display

Submitted by:  Dmitri A. Sergatskov <dasergatskov>
Submitted on:  Wed 09 Jun 2021 07:14:47 PM UTC  
 
Category:  Plotting Severity:  3 - Normal
Priority:  5 - Normal Item Group:  Incorrect Result
Status:  None Assigned to:  None
Originator Name:  Open/Closed:  Open
Release:  6.2.90 Operating System:  Microsoft Windows

Add a New Comment (Rich Markup)
   

You are not logged in

Please log in, so followups can be emailed to you.

 

Mon 14 Jun 2021 07:34:51 PM UTC, comment #4: 

Here it is (at 150% scaling):

>> t2_subplot
ans =

   300   200   560   420

ans =

   300   200   560   420

ans =

   0.1300   0.4414   0.1576   0.1521

ans =

   0.1300   0.6238   0.7750   0.3012

error: ASSERT errors for:  assert (ishghandle (hax),[false(1, 6), true(1, 3)])

  Location  |  Observed  |  Expected  |  Reason
    (4)           1            0         Abs err 1 exceeds tol 0 by 1
    (5)           1            0         Abs err 1 exceeds tol 0 by 1
    (6)           1            0         Abs err 1 exceeds tol 0 by 1
>>

Dmitri A. Sergatskov <dasergatskov>
Mon 14 Jun 2021 03:28:47 PM UTC, comment #3: 

Afaict, `subplot` only takes the "position" property into account for the check for overlapping axes. That is only the extent of the axes themselves (not including the labels and tick labels). See also the blue box in `demo annotation 2`.
So, axes font and fontsize shouldn't make a difference (and they don't).

Could you please run the following on your hi-res display?

hf = figure ("visible", "off");
set (hf, "position", get (groot, "defaultfigureposition"));  # FIXME: This step shouldn't be necessary
get (groot, "defaultfigureposition")
get (hf, "position")
unwind_protect
  for ii = 1:9
    hax(ii) = subplot (3,3,ii);
  endfor
  subplot (3,3,1);
  assert (gca (), hax(1));
  get (hax(4), "position")
  subplot (2,1,1);
  get (gca, "position")
  assert (ishghandle (hax), [false(1,6), true(1,3)]);
unwind_protect_cleanup
  delete (hf);
end_unwind_protect

For me:

ans =

   300   200   560   420

ans =

   300   200   560   420

ans =

   0.1300   0.4253   0.1818   0.1844

ans =

   0.1300   0.5996   0.7750   0.3254

Fwiw, in Matlab R2021a:

ans =

        1256        1206         560         420


ans =

        1256        1206         560         420


ans =

    0.1300    0.4096    0.2134    0.2157


ans =

    0.1300    0.5838    0.7750    0.3412

So Matlab seems to choose slightly larger subplot axes.

Markus Mützel <mmuetzel>
Project Member
Thu 10 Jun 2021 06:10:57 PM UTC, comment #2: 

The modified test is still failing the same way.
Thu position numbers are different by few pixels at different resolution/scale factors.
Also the test passes on linux (on the same laptop).

Also, changing default axes font/fontsize does not seem to affect the test results, though say setting font to Calibri:24 makes subplots overlapped (attached).

Dmitri.
--


Dmitri A. Sergatskov <dasergatskov>
Thu 10 Jun 2021 01:29:14 PM UTC, comment #1: 

In the thread Dmitri linked in the OP, we found that the "position" property is off by a few pixels.
Copied together from across different postings, on Dmitri's monitor:

>> hf = figure();
>> get(hf, 'position')
ans =

   300   207   560   413

>> get(groot, 'defaultfigureposition')
ans =

   300   200   560   420

>> for ii=1:9 hax(ii) = subplot(3,3,ii); endfor
>> get(hax(4), 'position')
ans =

   0.1300   0.4421   0.1576   0.1508

>> hax_new = subplot (2,1,1);
>> get(hax_new, 'position')
ans =

   0.1300   0.6248   0.7750   0.3002

On my monitor:

>> hf = figure;
>> get(hf, 'position')
ans =

   300   204   560   416

>> get(groot, 'defaultfigureposition')
ans =

   300   200   560   420

>> for ii = 1:9
  hax(ii) = subplot (3,3,ii);
endfor
>> get(hax(4), 'position')
ans =

   0.1300   0.4255   0.1818   0.1840

>> hax_new = subplot (2,1,1);
>> get(hax_new, 'position')
ans =

   0.1300   0.5999   0.7750   0.3251

The failing BIST might just be a consequence of the figures having different sizes. In that case, subplot (probably correctly) uses different positions for the axes in the grid.
It looks like with that slightly different layout, the middle row of the 3x3 grid does not overlap with the upper axes of the 2x1 grid on Dmitri's monitor.
But they do on mine.

@Dmitri: Could you please test if this modified test works for you?

hf = figure ("visible", "off");
set (hf, "position", get (groot, "defaultfigureposition"));  # FIXME: This step shouldn't be necessary
unwind_protect
  for ii = 1:9
    hax(ii) = subplot (3,3,ii);
  endfor
  subplot (3,3,1);
  assert (gca (), hax(1));
  subplot (2,1,1);
  assert (ishghandle (hax),[false(1,6), true(1,3)]);
unwind_protect_cleanup
  delete (hf);
end_unwind_protect

Markus Mützel <mmuetzel>
Project Member
Wed 09 Jun 2021 07:14:47 PM UTC, original submission:  

test subplot is failing on Win10 laptop  with 4K (3840x2160) display:

>> test subplot
***** test
hf = figure ("visible", "off");
unwind_protect
   for ii = 1:9
     hax(ii) = subplot (3,3,ii);
   endfor
   subplot (3,3,1);
   assert (gca (), hax(1));
   subplot (2,1,1);
   assert (ishghandle (hax),[false(1,6), true(1,3)]);
unwind_protect_cleanup
   delete (hf);
end_unwind_protect
!!!!! test failed
ASSERT errors for:  assert (ishghandle (hax),[false(1, 6), true(1, 3)])

  Location  |  Observed  |  Expected  |  Reason
    (4)           1            0         Abs err 1 exceeds tol 0 by 1
    (5)           1            0         Abs err 1 exceeds tol 0 by 1
    (6)           1            0         Abs err 1 exceeds tol 0 by 1
>>
>> for ii = 1:9
     hax(ii) = subplot (3,3,ii);
   endfor
>>    subplot (3,3,1);
>>    assert (gca (), hax(1));
>>    subplot (2,1,1);
>> ishghandle (hax)
ans =

  0  0  0  1  1  1  1  1  1

>>

The output of

figure ();
for ii = 1:9
  hax(ii) = subplot (3,3,ii);
endfor
subplot (2,1,1);

is attached (this is with 200% display scaling).

The display scaling does not seem to matter, but if I reduce the display resolution to 2048x1152, the test passes
(at 2048x1536 it still fails).

The test passes in Fedora 34 on the same laptop, so it seems to be Win10 specific.

See additional discussion on https://octave.discourse.group/t/release-candidate-available/1227/32.

Dmitri.
--

Dmitri A. Sergatskov <dasergatskov>

 

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

Attach Files:
   
   
Comment:
   

Attached Files

 

Depends on the following items: None found

Items that depend on this one: None found

 

Carbon-Copy List
  • -email is unavailable- added by mmuetzel (Posted a comment)
  • -email is unavailable- added by dasergatskov (Submitted the item)
  •  

    Do you think this task is very important?
    If so, you can add your encouragement to it.
    This task has 0 encouragements so far.

    Only project members can vote.

     

     

     

    Follow 2 latest changes.

    Date Changed by Updated Field Previous Value => Replaced by
    2021-06-10 dasergatskov Attached File- => Added subplot_das_calibri24.png, #51541
    2021-06-09 dasergatskov Attached File- => Added subplot_das_201210608_1.png, #51534

    Back to the top


    Powered by Savane 3.6