ax[0].set_ylabel("Valor")
ax[1].set_ylabel("Máximos y Mínimos")
ax[2].set_ylabel("Fear and Greed")
ax[3].set_ylabel("Put Call Ratio")
ax[4].set_ylabel("T10Y2Y")
ax[5].set_ylabel("RASI")
ax[6].set_ylabel("Oscilador Mcclellan")
I'm trying to put all of these in a list comprehension, something like this but doesn't work:
[[ax[i].set_ylabel(x) for i in range(7)] for x in ['Valor', 'Máximos y Mínimos', 'Fear & Greed', 'Put Call Ratio', 'T10Y2Y', 'RASI', 'Oscilador Mcclellan']]
Can't get the number on ax[] with the exact string for each one. Any ideas?
CodePudding user response:
This is a job for enumerate
:
[ax[i].set_ylabel(x) for i, x in enumerate(['Valor', 'Máximos y Mínimos', 'Fear & Greed', 'Put Call Ratio', 'T10Y2Y', 'RASI', 'Oscilador Mcclellan'])]