Skip to content

make_axes_locatable : Colorbar in the middle instead of bottom while saving a pdf, png. #12624

Closed
@navdeeprana

Description

@navdeeprana

cax added using make_axes_locatable shows up at the middle of the image, instead of bottom while saving figures. I have tried .png and .pdf . The output from plt.show() is correct.

python 3.6.6 :: Anaconda custom (64-bit)
numpy version 1.15.3
matplotlib version 3.0.0

Here's a minimal script, which reproduces the result

import numpy as np
from matplotlib import pyplot as plt 
from mpl_toolkits.axes_grid1 import make_axes_locatable

epsilon = np.random.rand(128,128)
fig,ax = plt.subplots(figsize=(6,6))
cax = make_axes_locatable(ax).append_axes('bottom', size='5%', pad = 0.05)
im = ax.imshow(epsilon,origin='lower')
fig.colorbar(im,cax=cax,orientation='horizontal')
fig.tight_layout()
fig.savefig('test.png',dpi=200,bbox_inches='tight')
plt.show()

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions