bugGNU Octave - Bugs: bug #66222, subplot annotations preventing /...

 
 

bug #66222: subplot annotations preventing / not triggering plot resize

Submitter:  Muhali <muhali>
Submitted:  Mon 16 Sep 2024 11:24:49 AM UTC
   
 
Category:  Plotting Severity:  3 - Normal
Priority:  5 - Normal Item Group:  None
Status:  Confirmed Assigned to:  None
Originator Name:  Open/Closed:  * Open
Release:  * 9.2.0 Operating System:  * Any
Fixed Release:  None Planned Release:  None
* Mandatory Fields

Add a New Comment Rich Markup
   

Thu 17 Oct 2024 12:09:22 AM UTC, comment #5: 

noting that colorbar has the following FIXME note:


## FIXME: The algorithm for positioning in legend.m is much more sophisticated
##        and should be borrowed for colorbar.  One problem is that colorbar
##        positioning does not take in to account multi-line axes labels.


this might suggest why colorbar triggers a horizontal resize but not a vertical one.

Nicholas Jankowski <nrjank>
Group Member
Wed 16 Oct 2024 11:43:32 PM UTC, comment #4: 

marking this as Confirmed. just to summarize -

(1) it appears xlabel (and presumably y, z, etc labels) do not trigger any listeners to resize the plot.  making it obvious with a large font:


set(0, 'defaultaxesfontsize', 24);
subplot(1,2,1);
xlabel ('xlabel');


pushes the label off the bottom of the plot window. In matlab, the xlabel command forces a redraw so everything fits in the window.

It seems that a subplot command after this. a

subplot(1,2,2)

resizes both subplots so they fit with the xlabel.

this does seem specific to subplot.  if you replace the subplot command with, e.g., plot(1:4), the xlabel command will trigger a plot resize so things fit.

if apply xlabel after creating the second subplot, to either subplot, a vertical resize does occur.


subplot(1,2,1)
subplot(1,2,2)
xlabel('xlabel2')



subplot(1,2,1)
subplot(1,2,2)
subplot(1,2,1)
xlabel('xlabel2')


so, it seems the issue with xlabel not triggering a subplot resize only occurs with the first subplot?

(2) if you add a colorbar to the first subplot, colorbar triggers a horizontal resize to fit itself in the subplot space, but doesn't trigger a vertical resize, so the xlabel is still off window. 


set(0, 'defaultaxesfontsize', 24);
subplot(1,2,1);
xlabel ('xlabel');
colorbar;


a subsequent


subplot(1,2,2);
xlabel ('xlabel2');


only resizes the right subplot. the left one seems locked.


Unlike above, switching back to subplot 1 and then applying the label


subplot(1,2,1)
colorbar
subplot(1,2,2)
subplot(1,2,1)
xlabel('xlabel2')


does not trigger a resize.  colorbar seems to have locked the subplot size.

Nicholas Jankowski <nrjank>
Group Member
Fri 27 Sep 2024 08:37:47 PM UTC, comment #3: 

Thanks! I can reproduce the issue on both 9.2.1 and 10.0.
Playing around with this example I noticed at least two problems, which may or may not be related.

First of all, calling "xlable()" does not re-size the plot until
another "subplot()" is called:


octave:1> set(0, "defaultaxesfontsize", 24)
octave:2> subplot(1, 2, 1) ;
octave:3> xlabel("longitude")
octave:4> subplot(1, 2, 1) # has no effect
octave:5> subplot(1, 2, 2) # now Y-axis is re-sized to fit the label


Another one is that "colorbar()" seems to inhibits resizing of the axis (as in your original example). Somebody else needs to look at the code to figure out what is happening.
A workaround is to call "colorbar()" the last, e.g.:

octave:1> set(0, "defaultaxesfontsize", 24)
octave:2> subplot(1, 2, 1)
octave:3> xlabel("longitude")
octave:4> subplot(1, 2, 2)
octave:5> xlabel("longitude")
octave:6> subplot(1, 2, 1)
octave:7> colorbar


Dmitri.
--


 

Dmitri A. Sergatskov <dasergatskov>
Tue 17 Sep 2024 07:58:17 AM UTC, comment #2: 

sorry. You need to add

set(0, "defaultaxesfontsize", 24) ;

to make it more visible, see attached figure.


Muhali <muhali>
Mon 16 Sep 2024 03:19:35 PM UTC, comment #1: 

Can you post a screenshot? I do not see this problem with mine (flatpak 9.2.0 version, attached).


Dmitri.
--



Dmitri A. Sergatskov <dasergatskov>
Mon 16 Sep 2024 11:24:49 AM UTC, original submission:  

Using

subplot(1, 2, 1) ;
xlabel("longitude") ;
colorbar
subplot(1, 2, 2) ;
xlabel("longitude") ;

shows that colorbar distorts the vertical positioning.

Muhali <muhali>

 

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

Attach Files:
   
   
Comment:
   

Attached Files
file #56435:  foo.png added by muhali (37KiB - image/png)
file #56433:  colorbar_das.png added by dasergatskov (19KiB - image/png)

 

Depends on the following items: None found

Items that depend on this one: None found

 

Carbon-Copy List
  • -email is unavailable- added by nrjank (Posted a comment)
  • -email is unavailable- added by dasergatskov (Updated the item)
  • -email is unavailable- added by muhali (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 6 latest changes.

    Date Changed by Updated Field Previous Value => Replaced by
    2024-10-16 nrjank Summarysubplot annotations not properly resizing subplot annotations preventing / not triggering plot resize
    2024-10-16 nrjank StatusNone Confirmed
        Operating SystemGNU/Linux Any
        Summarycolorbar distorts vertical positioning of subplot subplot annotations not properly resizing
    2024-09-17 muhali Attached File- Added foo.png, #56435
    2024-09-16 dasergatskov Attached File- Added colorbar_das.png, #56433

    Back to the top

    Powered by Savane 3.14-f13d.
    Corresponding source code