Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork7.9k
Description
Bug report
Bug summary
The new experimental layout manager seems to produce a rather surprising alignment of two colorbars when one is shared by severalAxes
instances, and another one is simply stealing space from a singleAxes
instance. It seems like@jklymak might have a fix in mind, but he also have a day-job ^^: milestoning for 2.2 just in case he manages to have a shot in time for it.
NB: originally fromGitter.
Code for reproduction
importmatplotlib.pyplotaspltimportnumpyasnp# Dummy dataarr_shape= (64,256)vmin,vmax=80.0,120.0arr_A=np.random.uniform(low=vmin,high=vmax,size=arr_shape)arr_B=np.random.uniform(low=vmin,high=vmax,size=arr_shape)rel_error=100* (arr_A-arr_B)/arr_A# Plotting time!fig,axs=plt.subplots(3,1,constrained_layout=True)# Raw data arrays, with a shared colorbarforax,arr,lblin ((axs[0],arr_A,"Case A"), (axs[1],arr_B,"Case B")):_im0=ax.imshow(arr,vmin=vmin,vmax=vmax)ax.set_title(lbl)fig.colorbar(_im0,ax=axs[:2],label="Raw Data (a.u.)",aspect=2*20,pad=-12)# Relative difference at the bottom, with its own colorbarax=axs[2]_im1=ax.imshow(rel_error,cmap="coolwarm",vmin=min(rel_error.min(),-rel_error.max()),vmax=max(rel_error.max(),-rel_error.min()))ax.set_title("(A - B) / A")fig.colorbar(_im1,ax=axs[2],label="Difference (%)",aspect=20)# Cosmeticksforaxinaxs.flat:ax.set_xticks([])ax.set_yticks([])plt.show()
@jklymak I know, I know, it is not really “minimal”, but I was originally planning to show a use case rather than a MWE. And at least, it is a standalone example 😈.
Actual outcome
Expected outcome
Workaround
The figure in theExpected outcome section was produced by passing the supplementary parameter “pad=-12” in the relevant line:
fig.colorbar(_im0,ax=axs[:2],label="Raw Data (a.u.)",aspect=2*20,pad=-12)
Matplotlib version
- Operating system: Linux (Fedora 27)
- Matplotlib version: 2.2.0rc1 from conda
- Python version: 3.6 from conda
Edit: English