我有以下代码:
import pandas as pd
from pandas_datareader import data as web
import numpy as np
from scipy.stats import nbinom
import matplotlib.pyplot as plt
import datetime
data = web.get_data_yahoo('^GSPC', start, end)
data.plot(y='Close')
plt.title("newtitle " +start) <--- I want a string and pass a variable to the title
我希望能够传递变量和文本在标签领域的同时,但由于某种原因,我可以通过其中一个变量或string但不能同时。反正是有可能的是我能够通过两者兼而有之?
分析解答
您可以尝试这样做:
plt.title("newtitle{0}".format(start))
要么
plt.title(f'newtitle{start}')