user308827
user308827

Reputation: 22031

Space between words in matplotlib plot axis label

I want to print the foll. as x-axis label in matplotlib:

r'$Area (km^{2})$'

However, when I pass it along to plt.ylabel(r'$Area (km^{2})$'), the resulting plot does not have a space between Area and (km^{2}). How do I introduce a space between them?

Upvotes: 12

Views: 23746

Answers (2)

Butters
Butters

Reputation: 95

There are various way to introduce some space between characters. Depending on the size of the gap you want, you can use: "\", "\,", "\;", "\quad", "\qquad"

Here, you'll find a nice overview: https://www.overleaf.com/learn/latex/Spacing_in_math_mode

Upvotes: 1

Primer
Primer

Reputation: 10302

You need to add \ before space character:

`r'$Area\ (km^{2})$'`

Or move Area (with space) out of $...$ expression:

r'Area $(km^{2})$'

Upvotes: 26

Related Questions