So I'm running into trouble when trying to label individual plots (inside a loop) using a mix of variables and strings.
Here is the section I'm having trouble with:
plt.plot(wlist, elist, label=('ratio =',i)) #using this inside a loop
When I run it, it shows up on the legend as ('ratio =', #) where the # is whatever iteration it is on. I only want it to print as:
Ratio = #
(The parenthesis I added are part of the output I'm getting)
Thanks in advance!
CodePudding user response:
If the parentheses aren't needed, then you can pass an f-string
to the label
argument (you can read more about f-strings