Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/tensorflow/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python “透明的”;“覆盖”;matplotlib堆栈图_Python_Python 3.x_Matplotlib_Area - Fatal编程技术网

Python “透明的”;“覆盖”;matplotlib堆栈图

Python “透明的”;“覆盖”;matplotlib堆栈图,python,python-3.x,matplotlib,area,Python,Python 3.x,Matplotlib,Area,我有一个简单的堆栈图: import matplotlib.pyplot as plt label, color = ["R", "M"], ["green", "blue"] X = [x for x in range(101)] Y1 = [31.4*x for x in range(101)] Y2 = [26.51*x-250 if (26.51*x-250)>=0 else 0 for x in range(101)] Y3 = [31.4*x if 31.4*x <

我有一个简单的堆栈图:

import matplotlib.pyplot as plt

label, color = ["R", "M"], ["green", "blue"]
X = [x for x in range(101)]
Y1 =  [31.4*x for x in range(101)]
Y2 = [26.51*x-250 if (26.51*x-250)>=0 else 0 for x in range(101)]
Y3 =  [31.4*x if 31.4*x < 2400 else 2400 for x in range(101)]

plt.stackplot(X, Y1, Y2, labels=label, colors = color)
plt.fill_between(X,Y3,[2400 for x in range(101)], color = 'r')
plt.legend(loc=2)
plt.xlim(0,100)
plt.ylim(0,5600)
plt.show()
导入matplotlib.pyplot作为plt
标签,颜色=[“R”,“M”],[“绿色”,“蓝色”]
X=[X代表范围(101)内的X]
Y1=[31.4*x代表范围内的x(101)]
Y2=[26.51*x-250如果(26.51*x-250)>=0,则范围(101)内的x为0]
Y3=[31.4*x如果31.4*x<2400,则为31.4*x;如果x在范围(101)内,则为2400]
plt.stackplot(X,Y1,Y2,标签=标签,颜色=颜色)
plt.fill_介于(X,Y3,[2400代表范围(101)]内的X,颜色='r')
plt.图例(loc=2)
plt.xlim(0100)
plt.ylim(05600)
plt.show()
可能有更好的方法来显示我想要显示的内容,但我只想知道,如果可能的话,如何使用matplotlib使红色区域透明


如果我理解正确,您需要以下内容吗

在这种情况下,您可以在

import matplotlib.pyplot as plt

label, color = ["R", "M"], ["green", "blue"]
X = [x for x in range(101)]
Y1 =  [31.4*x for x in range(101)]
Y2 = [26.51*x-250 if (26.51*x-250)>=0 else 0 for x in range(101)]
Y3 =  [31.4*x if 31.4*x < 2400 else 2400 for x in range(101)]

plt.stackplot(X, Y1, Y2, labels=label, colors = color)
plt.fill_between(X,Y3,[2400 for x in range(101)], color = 'r', alpha=0.3)
plt.legend(loc=2)
plt.xlim(0,100)
plt.ylim(0,5600)
导入matplotlib.pyplot作为plt
标签,颜色=[“R”,“M”],[“绿色”,“蓝色”]
X=[X代表范围(101)内的X]
Y1=[31.4*x代表范围内的x(101)]
Y2=[26.51*x-250如果(26.51*x-250)>=0,则范围(101)内的x为0]
Y3=[31.4*x如果31.4*x<2400,则为31.4*x;如果x在范围(101)内,则为2400]
plt.stackplot(X,Y1,Y2,标签=标签,颜色=颜色)
在(X,Y3,[2400表示范围(101)]内的X之间填充,颜色='r',α=0.3)
plt.图例(loc=2)
plt.xlim(0100)
plt.ylim(05600)

从文档字符串中可以明显看出的内容。我应该自己想出来的。不,这正是我想要的,但我必须自己想出来。