# How to set space between the axis and the label in matplotlib

We Are Going To Discuss About How to set space between the axis and the label in matplotlib. So lets Start this Python Article.

## How to set space between the axis and the label in matplotlib

1. How to solve How to set space between the axis and the label in matplotlib

You can set bounding by using labelpad argument like this
`ax.set_ylabel('Y', rotation=0, labelpad=10)`
also you can add space after 'Y ' label in set_ylabel line as following
`ax.set_ylabel('Y ',rotation=0)`
Note:
As you mentioned you want the same spaces between both axis labels so you can set 'X' label using:
`ax.text(max(x)/2, -(max(y)/10),'X')`
and
'Y' label using:
`ax.text(-(max(x)/10), max(y)/2,'Y')`

2. How to set space between the axis and the label in matplotlib

You can set bounding by using labelpad argument like this
`ax.set_ylabel('Y', rotation=0, labelpad=10)`
also you can add space after 'Y ' label in set_ylabel line as following
`ax.set_ylabel('Y ',rotation=0)`
Note:
As you mentioned you want the same spaces between both axis labels so you can set 'X' label using:
`ax.text(max(x)/2, -(max(y)/10),'X')`
and
'Y' label using:
`ax.text(-(max(x)/10), max(y)/2,'Y')`

## Solution 1

You can set bounding by using labelpad argument like this

``````ax.set_ylabel('Y', rotation=0, labelpad=10)
``````

also you can add space after ‘Y ‘ label in set_ylabel line as following

``````ax.set_ylabel('Y ',rotation=0)
``````

Note:

As you mentioned you want the same spaces between both axis labels so you can set ‘X’ label using:

`````` ax.text(max(x)/2, -(max(y)/10),'X')
``````

and

‘Y’ label using:

`````` ax.text(-(max(x)/10), max(y)/2,'Y')
``````

Original Author Zalak Bhalani Of This Content

## Solution 2

If you adjust the horizontal position of the label, you will have the same space as usual.

``````ax.set_ylabel('Y', rotation=0, ha='right')
``````

If you need more space, you can use the following settings.

``````ax.yaxis.labelpad = 20
``````

Original Author r-beginners Of This Content

## Conclusion

So This is all About This Tutorial. Hope This Tutorial Helped You. Thank You.