Menu

[r4674]: / trunk / htdocs / examples / fill_between.py  Maximize  Restore  History

Download this file

30 lines (22 with data), 581 Bytes

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
#!/usr/bin/env python
import matplotlib.mlab as mlab
from pylab import figure, show
import numpy as npy
x = npy.arange(0, 2, 0.01)
y1 = npy.sin(2*npy.pi*x)
y2 = npy.sin(4*npy.pi*x) + 2
fig = figure()
ax = fig.add_subplot(311)
ax2 = fig.add_subplot(312)
ax3 = fig.add_subplot(313)
xs, ys = mlab.poly_between(x, 0, y1)
ax.fill(xs, ys)
ax.set_ylabel('between y1 and 0')
xs, ys = mlab.poly_between(x, y1, 1)
ax2.fill(xs, ys)
ax2.set_ylabel('between y1 and 1')
xs, ys = mlab.poly_between(x, y1, y2)
ax3.fill(xs, ys)
ax3.set_ylabel('between y1 and y2')
ax3.set_xlabel('x')
show()
Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.