I need to type Greek letters and the Angstrom symbol in labels of axes in a plot. So for example
fig.gca().set_xlabel("$wavelength\, (Angstrom)$") fig.gca().set_ylabel("$lambda$")
except that I actually want "Angstrom" and "lambda" replaced by actual symbols. How should I do this? Thanks!
You can already use Greek letter variable names in Python: https://stackoverflow... | Hacker News. You can already use Greek letter variable names in Python: https://stackoverflow.com/questions/17043894/what-unicode-sy... I've used θ in code dealing with angles before.
Python gamma() is an inbuilt method that is defined under the math module, which is used to find the gamma value of the number parameter passed. For instance, if x is passed as a parameter in gamma function (gamma(x)), it returns the gamma value of the number. We can use the math module by importing it.
You need to make the strings raw and use latex:
fig.gca().set_ylabel(r'$\lambda$')
As of matplotlib 2.0 the default font supports most western alphabets and can simple do
ax.set_xlabel('λ')
with unicode.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With