Categories
computing python Uncategorized

Distance between axes-label and axes in matplotlib

There is useful option in matplotlib, which is quite obscure on the internet, given how useful it is, so it goes into the blog. In a plot, the distance between the axeslabel and the axes can be tuned by adding an argument labelpad which when positive increases the distance and which when negative decreases it. The syntax is just

plt.xlabel("x",labelpad=10)

.

As an example, the two plots below correspond to labelpad=10 and labelpad=-10
sin1sin2
 

Leave a Reply

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

WordPress.com Logo

You are commenting using your WordPress.com 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