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()
Original: https://blog.csdn.net/weixin_30884743/article/details/113961479
Author: 滴哩滴哩
Title: python facecolor_matplotlib facecolor多种颜色所有结果b
原创文章受到原创版权保护。转载请注明出处:https://www.johngo689.com/767920/
转载文章受原作者版权保护。转载请注明原作者出处!