[英]matplotlib fill in between step function
I need to plot a step function in matplotlib (because that's the correct interpretation of my data) and would like to fill between the x-axis and the step curve.我需要在 matplotlib 中绘制一个阶跃函数(因为这是对我的数据的正确解释)并且想在 x 轴和阶跃曲线之间进行填充。 Something like fill_between
, only that this one does not work with drawstyle
.类似fill_between
的东西,只是这个不适用于drawstyle
。
See minimal example below:请参阅下面的最小示例:
import numpy as np
import matplotlib.pyplot as plt
np.random.seed(2)
x = np.arange(50)
y = np.random.rand(50)
fig = plt.figure()
ax = fig.add_subplot(111)
ax.plot(x, y, drawstyle='steps-post')
ax.fill_between(x, y, drawstyle='steps-post') # does not work
plt.show()
You can use ax.fill_between(x, y, step='post')
.您可以使用ax.fill_between(x, y, step='post')
。 fill_between
doesn't have the parameter of drawstyle
. fill_between
没有drawstyle
的参数。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.