How to fix height of colorbar in Matplotlib

When a colorbar is used in a Matplotlib plot, it is usually drawn with a height that is larger than the plot itself. Many solutions to this problem are suggested here. The one that worked for me was this:

plt.colorbar(im, fraction=0.046, pad=0.04)

This sets the colorbar height equal to the height of the plot for me.

Tried with: Matplotlib 1.3.1-1, Python 2.7.6 and Ubuntu 14.04


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.