I have a series of variables that appear like this:
halpha = 6562.8
hbeta = 4861
ca1 = 8498
ca2 = 8542
ca3 = 8662
o3 = 5008.240
I have a plotting function here:
def abslines(molecule,title):
plt.axvline(molecule, color = "r", label=title)
plt.text(molecule-100, 40, title,rotation=90,fontsize=20)
And it works when input looks like:
abslines(he,"he")
And the function works just fine, but I don't want to have a ton of lines where I just call the function for each of the variables, so I put the variables in an array, and in a for loop I call the function. How do I call the variable name, which is the second input of the abslines
function?
absarray = [halpha,hbeta,ca1,ca2,ca3,o3,na,mg,he]
for i in absarray:
abslines(i,"i")