Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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?

like image 941
user308827 Avatar asked Jan 10 '16 03:01

user308827


1 Answers

You need to add \ before space character:

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

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

r'Area $(km^{2})$'
like image 119
Primer Avatar answered Oct 26 '22 06:10

Primer