File tree Expand file tree Collapse file tree 1 file changed +34
-0
lines changed
Expand file tree Collapse file tree 1 file changed +34
-0
lines changed Original file line number Diff line number Diff line change 1+ #!/usr/bin/env python
2+
3+ # implement the example graphs/integral from pyx
4+ from pylab import *
5+ from matplotlib .patches import Polygon
6+
7+ def func (x ):
8+ return (x - 3 )* (x - 5 )* (x - 7 )+ 85
9+
10+ ax = subplot (111 )
11+
12+ a , b = 2 , 9 # integral area
13+ x = arange (0 , 10 , 0.01 )
14+ y = func (x )
15+ plot (x , y , linewidth = 1 )
16+
17+ # make the shaded region
18+ ix = arange (a , b , 0.01 )
19+ iy = func (ix )
20+ verts = [(a ,0 )] + list (zip (ix ,iy )) + [(b ,0 )]
21+ poly = Polygon (verts , facecolor = '0.8' , edgecolor = 'k' )
22+ ax .add_patch (poly )
23+
24+ text (0.5 * (a + b ), 30 ,
25+ r"$\int_a^b f(x)\mathrm{d}x$" , horizontalalignment = 'center' ,
26+ fontsize = 20 )
27+
28+ axis ([0 ,10 , 0 , 180 ])
29+ figtext (0.9 , 0.05 , 'x' )
30+ figtext (0.1 , 0.9 , 'y' )
31+ ax .set_xticks ((a ,b ))
32+ ax .set_xticklabels (('a' ,'b' ))
33+ ax .set_yticks ([])
34+ show ()
You can’t perform that action at this time.
0 commit comments