Skip to content

The plots/layout are messy/confused/disorganized. #306

@nickbsb

Description

@nickbsb

When plotting 6 subplots using GridSpec, I want the colorbar of the 3rd subplot on the left to be aligned (horizontally level) with the 3rd subplot on the right. However, The plots/layout are messy.
import matplotlib as mpl

gs = uplt.GridSpec(nrows=4, ncols=2, pad=1,wratios=(1, 1),
hratios=(1, 1.4,1.6,0.01))
fig = uplt.figure(span=False, refwidth=2)
ax1 = fig.add_subplot(gs[0, 0])
ax1.heatmap(
df_pc1_selfeat_r ,
cmap=cmap,
labels=True,
precision=2,norm=norm,
labels_kw={"weight": "light"},
)
ax2 = fig.add_subplot(gs[1, 0])
m2 = ax2.heatmap(
df_pc2_selfeat_r ,
cmap=cmap,
labels=True,
precision=2,norm=norm,
labels_kw={"weight": "light"},
)
ax3 = fig.add_subplot(gs[2, 0])
m3 = ax3.heatmap(
df_pc3_selfeat_r ,
cmap=cmap,
labels=True,
precision=2,norm=norm,
labels_kw={"weight": "light"},
#colorbar="b",
)
ax4 = fig.add_subplot(gs[3, 0])
plt.colorbar(mpl.cm.ScalarMappable(norm=norm, cmap=cmap),
cax=ax4,orientation="horizontal")

ax5 = fig.subplot(gs[0, 1])
ax5.plot(range(5))
ax6 = fig.subplot(gs[1, 1])
ax6.plot(range(5))
ax7 = fig.subplot(gs[2:4, 1])
ax7.plot(range(5))

Image
If I omit the line that adds the colorbar, then there is no problem.

Metadata

Metadata

Assignees

No one assigned

    Labels

    invalidThis doesn't seem rightquestionFurther information is requested

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions