我正在循环绘制图形:
cities = grouped_price.index.levels[0] # list of cities
dates = grouped_price.index.levels[1] # list of dates, which
# are 1st day of each month
linestyles = ['-', '-.', '--', '-.-', ':']
for city in cities[0:1]:
for month in dates: # loop over dates, which are grouped by month
legend = legend + [month.strftime("%B")] # month in text
ax = grouped_price.loc[city, month]['Amount'].plot()
plt.show()
之后如何设置线条样式?如果我写
ax = grouped_price.loc[city, week]['Amount'].plot(style = linestyles)
在循环内部,它只对所有行使用第一个线条样式。
与颜色和线条粗细相同的问题。我找到了一个设置厚度的迭代解决方案(在每一行上循环),但有没有更简单的方法?谢谢。