繁体   English   中英

matplotlib 在 step 函数之间填充

[英]matplotlib fill in between step function

我需要在 matplotlib 中绘制一个阶跃函数(因为这是对我的数据的正确解释)并且想在 x 轴和阶跃曲线之间进行填充。 类似fill_between的东西,只是这个不适用于drawstyle

请参阅下面的最小示例:

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()

您可以使用ax.fill_between(x, y, step='post') fill_between没有drawstyle的参数。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM