【发布时间】:2020-09-19 21:49:08
【问题描述】:
我正在使用 Matplotlib 生成一个订单簿图表,该图表已生成,但我很难弄清楚如何为其设置背景颜色。在图表上,我为每一方绘制了 2 个订单簿,为此我在我的数据上使用了一个简单的循环:
fig = plt.figure(facecolor='#131722',dpi=135, figsize=(5, 3))
ax1 = plt.subplot2grid((2,1), (0,0), rowspan=6, colspan=4, facecolor='#131722')
Colors = [['#2BBB2B', '#FF0000'], ['#09ff00', '#ff8c00']]
for x in List:
Index = List.index(x)
print(Index)
rate_buy = []
total_buy = []
rate_sell = []
total_sell = []
for y in x['data']['asks']:
rate_sell.append(y[0])
total_sell.append(y[1])
for y in x['data']['bids']:
rate_buy.append(y[0])
total_buy.append(y[1])
rBuys = pd.DataFrame({'buy': rate_buy})
rSells = pd.DataFrame({'sell': rate_sell})
tBuys = pd.DataFrame({'total': total_buy})
tSells = pd.DataFrame({'total': total_sell})
plt.plot(rBuys.buy, tBuys.total, color=Colors[Index][0], linewidth=0.9, alpha=0.9)
plt.plot(rSells.sell, tSells.total, color=Colors[Index][1],alpha=0.3, linewidth=0.9)
所以基本上,我想做的是将图表内部的区域设置为与值Color 相同的颜色。我该怎么做?
【问题讨论】:
标签: python python-3.x matplotlib background area