本文介绍了用 Python 填充两行之间的区域的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在寻找填充matplot中两行之间的区域.有什么办法吗?

I am looking for fill the area between two lines in matplot. Any way to do this?

a = [[12, 17, 26, 32, 34], [235.910888671875, 245.84429931640625, 211.8711395263672, 226.2964630126953, 222.0032501220703]]
b = [[12, 26, 34], [235.910888671875, 211.8711395263672, 222.0032501220703]]

plt.plot(a[0], a[1], c='r')
plt.plot(b[0], b[1], c='r')

推荐答案

在这里是

import matplotlib.pyplot as plt
import numpy as np
a = [[12, 17, 26, 32, 34], [235.910888671875, 245.84429931640625, 211.8711395263672, 226.2964630126953, 222.0032501220703]]
b = [[12, 26, 34], [235.910888671875, 211.8711395263672, 222.0032501220703]]

plt.plot(a[0], a[1], c='r')
plt.plot(b[0], b[1], c='r')
plt.fill_between(a[0], a[1],np.min(a[1]))
plt.fill_between(b[0], b[1],np.min(a[1]),color='white')
plt.show()

这篇关于用 Python 填充两行之间的区域的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-25 02:46