【发布时间】:2017-07-24 06:45:45
【问题描述】:
我正在绘制行业及其中所有股票的回报。我希望值 > 100 为绿色,
sector_lst = ['XLK','XLF','XLE'] ## etc.
for i in sector_lst:
fig = plt.figure(figsize=(12, 8))
for x in sectordict[i]: #sectordict[i] is all the stocks in a sector (so AAPL, GOOG, etc. for tech)
if pct_change[x] > 1:
pct_change[sectordict[i]].plot(kind='bar',color='g')
##if pct_chg < 1
else:
pct_change[sectordict[i]].plot(kind='bar',color='r')
plt.title(i)
到目前为止,这会将整个扇区图返回为绿色或红色;如果第一个值 > 100,所有股票都将是绿色的,反之亦然。
我的预期输出是有 11 个图表(目前是这样),但图表中每只股票的颜色不同,如果股票的回报率 > 100%,则显示绿色,
【问题讨论】:
-
你能从你的 df 添加几行吗?单个部门
标签: python pandas matplotlib yahoo-finance