3

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

enter image description here

Antoine Delia
  • 1,728
  • 5
  • 26
  • 42
Martin Bouhier
  • 173
  • 1
  • 10

1 Answers1

2

Here it is:

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

Pic

razimbres
  • 4,715
  • 5
  • 23
  • 50