python facecolor_matplotlib facecolor多种颜色所有结果b

def plot_loads(ti, tf, loads, max_y):

"""

plot load curves

\param ti : init t

\param tf : final t

\param loads : list of load curve lists

loads = [[ load1], [load2], ...]

\param max_y : vertical limit."""

#imports

from matplotlib import pyplot as plt

import numpy as np

import random

ys_array = []

for item in loads:

ys_array.append(item)

y = np.row_stack(ys_array)

x = np.arange(ti, tf)

y_stack = np.cumsum(y, axis=0)

fig = plt.figure(random.randint(1,1000))

#plot frame positioning

ax1 = fig.add_subplot(211)

#plot maximum load

ax1.fill_between(x, 0, max_y, alpha=0.1, facecolor = 'black')

#

for i, item in enumerate(loads):

if i == 0:

ax1.fill_between( x, 0, y_stack[0,:], facecolor = random.choice(['g', 'r', 'c', 'm', 'y', 'k']))

else:

ax1.fill_between( x, y_stack[i-1,:], y_stack[i,:], facecolor =random.choice(['g', 'r', 'c', 'm', 'y', 'k']))

plt.show()

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值