gpt4 book ai didi

python - 可以更新 .fill_betweenx() 参数吗?如何?

转载 作者:太空宇宙 更新时间:2023-11-04 03:28:42 25 4
gpt4 key购买 nike

我知道可以通过使用带有 .set_xdata().set_ydata() 的艺术家来更新绘图的 x 和 y 值。

可以用 .fill_betweenx() 做类似的事情来更新它的参数( y, x1, x2where ) 以避免清除轴并再次绘制?

最佳答案

有点 hack,fill_between 返回的 PolyCollection 有一个 set_path 方法,但它似乎不起作用。必须直接将新的 Path 分配给 _path:

from matplotlib.path import Path

x = [0,2,3,4,5]
y = [1,4,5,6,7]
z = [4,5,6,7,8]
PC = plt.fill_between(x, y, z)
PC._paths = [Path(np.vstack([[1,1,2,3,4,5,5,5,4,3,2,1,1],
[4,3,4,5,6,7,8,8,7,6,5,4,4]]).T,
np.array([1,2,2,2,2,2,2,2,2,2,2,2,9]))]

之前

enter image description here

之后

enter image description here

关于python - 可以更新 .fill_betweenx() 参数吗?如何?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32013097/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com