Skip to content

Complex subplot grid: Attached colorbar disturbs intra-row horizontal spacing; wspace distorts subplot aspect ratio #855

Closed

Description

@xiaochen30

When using the complex nested grid syntax for uplt.subplots(), two layout coupling issues are observed:

  1. Attaching colorbar='r' to a subset of axes alters the horizontal spacing within different rows of the entire grid. The horizontal gap between panels within each row shifts visibly.
  2. The wspace parameter modifies the native width/aspect ratio of the plotting axes, instead of only inserting blank space between panels. Setting refaspect does not fix this behaviour.

Could you please help investigate this layout coupling issue.

Minimal reproducible example:
state = np.random.RandomState(51423)
x = y = np.array([-10, -5, 0, 5, 10])
data = state.rand(y.size, x.size)

Case 1

fig1, axs1 = uplt.subplots([[ 1, 1,2,2,3,3], [0,4,4,5,5,0]],refwidth=2.2)
axs1[0].contourf(x,y,data,colorbar='r')
axs1[1].contourf(x,y,data)
axs1[2].contourf(x,y,data,colorbar='r')
axs1[3].contourf(x,y,data,colorbar='r')
axs1[4].contourf(x,y,data,colorbar='r')

Case 2

fig2, axs2 = uplt.subplots([[ 1, 1,2,2,3,3], [0,4,4,5,5,0]],refwidth=2.2)
axs2[0].contourf(x,y,data,colorbar='r')
axs2[1].contourf(x,y,data)
axs2[2].contourf(x,y,data)
axs2[3].contourf(x,y,data,colorbar='r')
axs2[4].contourf(x,y,data,colorbar='r')

Case 3

fig3, axs3 = uplt.subplots([[ 1, 1,2,2,3,3], [0,4,4,5,5,0]],refwidth=2.2,wspace=4)
axs3[0].contourf(x,y,data,colorbar='r')
axs3[1].contourf(x,y,data)
axs3[2].contourf(x,y,data,colorbar='r')
axs3[3].contourf(x,y,data)
axs3[4].contourf(x,y,data,colorbar='r')

Activity

  1. added
    bug
    on Nov 4, 2026
  2. cvanelteren commented on Nov 4, 2026

    @cvanelteren
    Collaborator

    I think this may be related to how the solver deals with colorbars. I will need to do some digging.

  3. cvanelteren commented on Nov 4, 2026

    @cvanelteren
    Collaborator

    Thanks! Should be fixed on main now.

  4. xiaochen30 commented on Nov 5, 2026

    @xiaochen30
    Author

    Thanks a lot for looking into this and fixing it! Really appreciate your work.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bug

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions