使用格式化字符串在 matplotlib 中标记轴

Labeling an axis in matplotlib with formatting strings

我正在尝试将标签放在轴上,但我似乎遇到了错误。我想调用我之前在代码中设置的字符串的名称。

ticker = 'RY', 'CM' 

然后后面我给图命名的时候就叫名字了

plt.ylabel('Price Spread between %s and %s') % (ticker[0], ticker[1])

但是,我得到这个错误:

TypeError: unsupported operand type(s) for %: 'Text' and 'tuple'

我做错了什么?

将代码中的格式行更改为,

plt.ylabel('Price Spread between %s and %s' % (ticker[0], ticker[1]))