Home > Back-end >  Writting variables in math format in matplotlib label
Writting variables in math format in matplotlib label

Time:03-03

I have a list of variables that are Greek letters (56 variables so too many to do it per Hand). I would like to write those Greek letters in a matplotlib xlabel that it shows something like this in the xlabel:

enter image description here

I tried the following code:

my_variable_list = ['\theta_m','\Omega_b h**2',..........,'log(A)']
plt.xlabel(r' $%s$ ' % my_variable_list[1])

but this doesn't work... It shows:

enter image description here

Does someone have an idea on how to do this?

CodePudding user response:

It's working for me with %s, if '\theta' didnt work use '\\theta'.

enter image description here

  • Related