##// END OF EJS Templates
cleanup profile fixup rst
Matthias BUSSONNIER -
Show More
@@ -1,11 +1,10 b''
1 1 c = get_config()
2 2
3 3
4 c.ConverterTemplate.extract_figures=False
5 4 c.ConverterTemplate.template_file='basichtml'
6 5 c.ConverterTemplate.tex_environement=False
7 6
8 7 c.NbconvertApp.fileext='html'
9 8
10 c.ExtractFigureTransformer.enabled = False
9 c.ExtractFigureTransformer.enabled=False
11 10 c.CSSHtmlHeaderTransformer.enabled=True
@@ -1,5 +1,6 b''
1 1 c = get_config()
2
2 3 load_subconfig('base_html.nbcv')
3 4
4 5 c.ConverterTemplate.template_file='fullhtml'
5 6
@@ -1,11 +1,15 b''
1 1 c = get_config()
2 2
3 c.ConverterTemplate.extract_figures=True
4 3 c.ConverterTemplate.template_file='latex_base'
5 4 c.ConverterTemplate.tex_environement=True
6 c.ConverterTemplate.display_data_priority=['latex', 'svg', 'png', 'jpg', 'jpeg' , 'text']
7 c.ExtractFigureTransformer.display_data_priority=['latex', 'svg', 'png', 'jpg', 'jpeg']
5
6
8 7 c.NbconvertApp.fileext='tex'
9 8
9 c.GlobalConfigurable.display_data_priority =['latex', 'svg', 'png', 'jpg', 'jpeg' , 'text']
10 # do not extract text
11 c.ExtractFigureTransformer.display_data_priority=['latex', 'svg', 'png', 'jpg', 'jpeg']
12
13
10 14 c.ExtractFigureTransformer.extra_ext_map={'svg':'pdf'}
11 15 c.ExtractFigureTransformer.enabled=True
@@ -1,7 +1,6 b''
1 1 c = get_config()
2 2
3 c.ConverterTemplate.extract_figures=False
4 3 c.ConverterTemplate.template_file='python'
5 4 c.ConverterTemplate.tex_environement=False
6 5
7 6 c.NbconvertApp.fileext='py'
@@ -1,13 +1,13 b''
1 1 c = get_config()
2 2
3 c.ConverterTemplate.extract_figures=True
4 3 c.ConverterTemplate.template_file='rst'
5 4 c.ConverterTemplate.tex_environement=False
6 5
7 6 c.NbconvertApp.fileext='rst'
8 7 c.ExtractFigureTransformer.enabled=True
9 8
9 c.GlobalConfigurable.display_data_priority =['svg', 'png', 'latex', 'jpg', 'jpeg','text']
10 10 c.ExtractFigureTransformer.display_data_priority=['svg', 'png', 'latex', 'jpg', 'jpeg','text']
11 11 c.ConverterTemplate.display_data_priority= ['svg', 'png', 'latex', 'jpg', 'jpeg','text']
12 12
13 13
1 NO CONTENT: file renamed from tests/ipynbref/00_notebook_tour.orig.rst to tests/ipynbref/00_notebook_tour_orig.rst
@@ -1,633 +1,660 b''
1 1 A brief tour of the IPython notebook
2 2 ====================================
3 3
4 4 This document will give you a brief tour of the capabilities of the
5 5 IPython notebook.
6 6 You can view its contents by scrolling around, or execute each cell by
7 7 typing ``Shift-Enter``. After you conclude this brief high-level tour,
8 8 you should read the accompanying notebook titled
9 9 ``01_notebook_introduction``, which takes a more step-by-step approach
10 10 to the features of the system.
11 11
12 12 The rest of the notebooks in this directory illustrate various other
13 13 aspects and capabilities of the IPython notebook; some of them may
14 14 require additional libraries to be executed.
15 15
16 16 **NOTE:** This notebook *must* be run from its own directory, so you
17 17 must ``cd`` to this directory and then start the notebook, but do *not*
18 18 use the ``--notebook-dir`` option to run it from another location.
19 19
20 20 The first thing you need to know is that you are still controlling the
21 21 same old IPython you're used to, so things like shell aliases and magic
22 22 commands still work:
23 23
24 24 In[1]:
25 25
26 26 .. code:: python
27 27
28 28 pwd
29 29
30 30 Out[1]:
31 31 .. parsed-literal::
32 32
33 33 u'/Users/minrk/dev/ip/mine/docs/examples/notebooks'
34 34
35 35
36 36 In[2]:
37 37
38 38 .. code:: python
39 39
40 40 ls
41 41
42 42
43 43 .. parsed-literal::
44 44
45 45 00_notebook_tour.ipynb callbacks.ipynb python-logo.svg
46 46 01_notebook_introduction.ipynb cython_extension.ipynb rmagic_extension.ipynb
47 47 Animations_and_Progress.ipynb display_protocol.ipynb sympy.ipynb
48 48 Capturing Output.ipynb formatting.ipynb sympy_quantum_computing.ipynb
49 49 Script Magics.ipynb octavemagic_extension.ipynb trapezoid_rule.ipynb
50 50 animation.m4v progbar.ipynb
51 51
52 52 In[3]:
53 53
54 54 .. code:: python
55 55
56 56 message = 'The IPython notebook is great!'
57 57 # note: the echo command does not run on Windows, it's a unix command.
58 58 !echo $message
59 59
60 60
61 61 .. parsed-literal::
62 62
63 63 The IPython notebook is great!
64 64
65 65 Plots with matplotlib
66 66 ---------------------
67 67
68
69 68 IPython adds an 'inline' matplotlib backend, which embeds any matplotlib
70 69 figures into the notebook.
71 70
72 71 In[4]:
73 72
74 73 .. code:: python
75 74
76 75 %pylab inline
77 76
78 77
79 78 .. parsed-literal::
80 79
81 80
82 81 Welcome to pylab, a matplotlib-based Python environment [backend: module://IPython.zmq.pylab.backend_inline].
83 82 For more information, type 'help(pylab)'.
84 83
85 84 In[5]:
86 85
87 86 .. code:: python
88 87
89 88 x = linspace(0, 3*pi, 500)
90 89 plot(x, sin(x**2))
91 90 title('A simple chirp');
92 91
93 92 .. image:: _fig_07.png
94 93
95 94 You can paste blocks of input with prompt markers, such as those from
96 95 `the official Python
97 96 tutorial <http://docs.python.org/tutorial/interpreter.html#interactive-mode>`_
98 97
99 98 In[6]:
100 99
101 100 .. code:: python
102 101
103 102 >>> the_world_is_flat = 1
104 103 >>> if the_world_is_flat:
105 104 ... print "Be careful not to fall off!"
106 105
107 106
108 107 .. parsed-literal::
109 108
110 109 Be careful not to fall off!
111 110
112 111 Errors are shown in informative ways:
113 112
114 113 In[7]:
115 114
116 115 .. code:: python
117 116
118 117 %run non_existent_file
119 118
120 119
121 120 .. parsed-literal::
122 121
123 122 ERROR: File `u'non_existent_file.py'` not found.
124 123 In[8]:
125 124
126 125 .. code:: python
127 126
128 127 x = 1
129 128 y = 4
130 129 z = y/(1-x)
131 130
132 131 ::
133 132
134 133 ---------------------------------------------------------------------------
135 134 ZeroDivisionError Traceback (most recent call last)
136 135 <ipython-input-8-dc39888fd1d2> in <module>()
137 136 1 x = 1
138 137 2 y = 4
139 138 ----> 3 z = y/(1-x)
140 139
141 140 ZeroDivisionError: integer division or modulo by zero
142 141 When IPython needs to display additional information (such as providing
143 142 details on an object via ``x?`` it will automatically invoke a pager at
144 143 the bottom of the screen:
145 144
146 145 In[18]:
147 146
148 147 .. code:: python
149 148
150 149 magic
151 150
152 151 Non-blocking output of kernel
153 152 -----------------------------
154 153
155 154 If you execute the next cell, you will see the output arriving as it is
156 155 generated, not all at the end.
157 156
158 157 In[19]:
159 158
160 159 .. code:: python
161 160
162 161 import time, sys
163 162 for i in range(8):
164 163 print i,
165 164 time.sleep(0.5)
166 165
167 166
168 167 .. parsed-literal::
169 168
170 169 0 1 2 3 4 5 6 7
170
171 171 Clean crash and restart
172 172 -----------------------
173 173
174 174 We call the low-level system libc.time routine with the wrong argument
175 175 via ctypes to segfault the Python interpreter:
176 176
177 177 In[*]:
178 178
179 179 .. code:: python
180 180
181 181 import sys
182 182 from ctypes import CDLL
183 183 # This will crash a Linux or Mac system; equivalent calls can be made on Windows
184 184 dll = 'dylib' if sys.platform == 'darwin' else '.so.6'
185 185 libc = CDLL("libc.%s" % dll)
186 186 libc.time(-1) # BOOM!!
187 187
188 188 Markdown cells can contain formatted text and code
189 189 --------------------------------------------------
190 190
191 191 You can *italicize*, **boldface**
192 192
193 193 - build
194 194 - lists
195 195
196 196 and embed code meant for illustration instead of execution in Python:
197 197
198 198 ::
199 199
200 200 def f(x):
201 201 """a docstring"""
202 202 return x**2
203 203
204 204 or other languages:
205 205
206 206 ::
207 207
208 208 if (i=0; i<n; i++) {
209 209 printf("hello %d\n", i);
210 210 x += 4;
211 211 }
212 212
213 213
214 214 Courtesy of MathJax, you can include mathematical expressions both
215 215 inline: :math:`e^{i\pi} + 1 = 0` and displayed:
216 216
217 217 .. math:: e^x=\sum_{i=0}^\infty \frac{1}{i!}x^i
218 218
219 219
220 220
221 221 Rich displays: include anyting a browser can show
222 222 -------------------------------------------------
223 223
224 224 Note that we have an actual protocol for this, see the
225 225 ``display_protocol`` notebook for further details.
226 226
227 227 Images
228 228 ~~~~~~
229 229
230 230
231 231 In[1]:
232 232
233 233 .. code:: python
234 234
235 235 from IPython.display import Image
236 236 Image(filename='../../source/_static/logo.png')
237 237
238 238 Out[1]:
239 239 .. image:: _fig_22.png
240 240
241 241
242 242 An image can also be displayed from raw data or a url
243 243
244 244 In[2]:
245 245
246 246 .. code:: python
247 247
248 248 Image(url='http://python.org/images/python-logo.gif')
249 249
250 250 Out[2]:
251 .. parsed-literal::
252
253 <IPython.core.display.Image at 0x1060e7410>
254
251 255
252 256 SVG images are also supported out of the box (since modern browsers do a
253 257 good job of rendering them):
254 258
255 259 In[3]:
256 260
257 261 .. code:: python
258 262
259 263 from IPython.display import SVG
260 264 SVG(filename='python-logo.svg')
261 265
262 266 Out[3]:
263 267 .. image:: _fig_26.svg
264 268
265 269
266 270 Embedded vs Non-embedded Images
267 271 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
268 272
269 273
270 274 As of IPython 0.13, images are embedded by default for compatibility
271 275 with QtConsole, and the ability to still be displayed offline.
272 276
273 277 Let's look at the differences:
274 278
275 279 In[4]:
276 280
277 281 .. code:: python
278 282
279 283 # by default Image data are embedded
280 284 Embed = Image( 'http://scienceview.berkeley.edu/view/images/newview.jpg')
281 285
282 286 # if kwarg `url` is given, the embedding is assumed to be false
283 287 SoftLinked = Image(url='http://scienceview.berkeley.edu/view/images/newview.jpg')
284 288
285 289 # In each case, embed can be specified explicitly with the `embed` kwarg
286 290 # ForceEmbed = Image(url='http://scienceview.berkeley.edu/view/images/newview.jpg', embed=True)
287 291
288 292 Today's image from a webcam at Berkeley, (at the time I created this
289 293 notebook). This should also work in the Qtconsole. Drawback is that the
290 294 saved notebook will be larger, but the image will still be present
291 295 offline.
292 296
293 297 In[5]:
294 298
295 299 .. code:: python
296 300
297 301 Embed
298 302
299 303 Out[5]:
300 304 ..jpg image::
301 305
302 306
303 307 Today's image from same webcam at Berkeley, (refreshed every minutes, if
304 308 you reload the notebook), visible only with an active internet
305 309 connexion, that should be different from the previous one. This will not
306 310 work on Qtconsole. Notebook saved with this kind of image will be
307 311 lighter and always reflect the current version of the source, but the
308 312 image won't display offline.
309 313
310 314 In[6]:
311 315
312 316 .. code:: python
313 317
314 318 SoftLinked
315 319
316 320 Out[6]:
321 .. parsed-literal::
322
323 <IPython.core.display.Image at 0x10fb99b10>
324
317 325
318 326 Of course, if you re-run the all notebook, the two images will be the
319 327 same again.
320 328
321 329 Video
322 330 ~~~~~
323 331
324 332
325 333 And more exotic objects can also be displayed, as long as their
326 334 representation supports the IPython display protocol.
327 335
328 336 For example, videos hosted externally on YouTube are easy to load (and
329 337 writing a similar wrapper for other hosted content is trivial):
330 338
331 339 In[7]:
332 340
333 341 .. code:: python
334 342
335 343 from IPython.display import YouTubeVideo
336 344 # a talk about IPython at Sage Days at U. Washington, Seattle.
337 345 # Video credit: William Stein.
338 346 YouTubeVideo('1j_HxD4iLn8')
339 347
340 348 Out[7]:
349 .. parsed-literal::
350
351 <IPython.lib.display.YouTubeVideo at 0x10fba2190>
352
341 353
342 354 Using the nascent video capabilities of modern browsers, you may also be
343 355 able to display local videos. At the moment this doesn't work very well
344 356 in all browsers, so it may or may not work for you; we will continue
345 357 testing this and looking for ways to make it more robust.
346 358
347 359 The following cell loads a local file called ``animation.m4v``, encodes
348 360 the raw video as base64 for http transport, and uses the HTML5 video tag
349 361 to load it. On Chrome 15 it works correctly, displaying a control bar at
350 362 the bottom with a play/pause button and a location slider.
351 363
352 364 In[8]:
353 365
354 366 .. code:: python
355 367
356 368 from IPython.display import HTML
357 369 video = open("animation.m4v", "rb").read()
358 370 video_encoded = video.encode("base64")
359 371 video_tag = '<video controls alt="test" src="data:video/x-m4v;base64,{0}">'.format(video_encoded)
360 372 HTML(data=video_tag)
361 373
362 374 Out[8]:
375 .. parsed-literal::
376
377 <IPython.core.display.HTML at 0x10fba28d0>
378
363 379
364 380 Local Files
365 381 -----------
366 382
367 383 The above examples embed images and video from the notebook filesystem
368 384 in the output areas of code cells. It is also possible to request these
369 385 files directly in markdown cells if they reside in the notebook
370 386 directory via relative urls prefixed with ``files/``:
371 387
372 388 ::
373 389
374 390 files/[subdirectory/]<filename>
375 391
376 392 For example, in the example notebook folder, we have the Python logo,
377 393 addressed as:
378 394
379 395 ::
380 396
381 397 <img src="files/python-logo.svg" />
382 398
383 399 and a video with the HTML5 video tag:
384 400
385 401 ::
386 402
387 403 <video controls src="files/animation.m4v" />
388 404
389 405 These do not embed the data into the notebook file, and require that the
390 406 files exist when you are viewing the notebook.
391 407
392 408 Security of local files
393 409 ~~~~~~~~~~~~~~~~~~~~~~~
394 410
395 411 Note that this means that the IPython notebook server also acts as a
396 412 generic file server for files inside the same tree as your notebooks.
397 413 Access is not granted outside the notebook folder so you have strict
398 414 control over what files are visible, but for this reason it is highly
399 415 recommended that you do not run the notebook server with a notebook
400 416 directory at a high level in your filesystem (e.g. your home directory).
401 417
402 418 When you run the notebook in a password-protected manner, local file
403 419 access is restricted to authenticated users unless read-only views are
404 420 active.
405 421
406 422 Linking to files and directories for viewing in the browser
407 423 -----------------------------------------------------------
408 424
409 425 It is also possible to link directly to files or directories so they can
410 426 be opened in the browser. This is especially convenient if you're
411 427 interacting with a tool within IPython that generates HTML pages, and
412 428 you'd like to easily be able to open those in a new browser window.
413 429 Alternatively, if your IPython notebook server is on a remote system,
414 430 creating links provides an easy way to download any files that get
415 431 generated.
416 432
417 433 As we saw above, there are a bunch of ``.ipynb`` files in our current
418 434 directory.
419 435
420 436 In[1]:
421 437
422 438 .. code:: python
423 439
424 440 ls
425 441
426 442
427 443 .. parsed-literal::
428 444
429 445 00_notebook_tour.ipynb formatting.ipynb
430 446 01_notebook_introduction.ipynb octavemagic_extension.ipynb
431 447 Animations_and_Progress.ipynb publish_data.ipynb
432 448 Capturing Output.ipynb python-logo.svg
433 449 Script Magics.ipynb rmagic_extension.ipynb
434 450 animation.m4v sympy.ipynb
435 451 cython_extension.ipynb sympy_quantum_computing.ipynb
436 452 display_protocol.ipynb trapezoid_rule.ipynb
437 453
438 454 If we want to create a link to one of them, we can call use the
439 455 ``FileLink`` object.
440 456
441 457 In[2]:
442 458
443 459 .. code:: python
444 460
445 461 from IPython.display import FileLink
446 462 FileLink('00_notebook_tour.ipynb')
447 463
448 464 Out[2]:
465 .. parsed-literal::
466
467 <IPython.lib.display.FileLink at 0x10f7ea3d0>
468
449 469
450 470 Alternatively, if we want to link to all of them, we can use the
451 471 ``FileLinks`` object, passing ``'.'`` to indicate that we want links
452 472 generated for the current working directory. Note that if there were
453 473 other directories under the current directory, ``FileLinks`` would work
454 474 in a recursive manner creating links to files in all sub-directories as
455 475 well.
456 476
457 477 In[7]:
458 478
459 479 .. code:: python
460 480
461 481 from IPython.display import FileLinks
462 482 FileLinks('.')
463 483
464 484 Out[7]:
485 .. parsed-literal::
486
487 <IPython.lib.display.FileLinks at 0x10f7eaad0>
488
465 489
466 490 External sites
467 491 ~~~~~~~~~~~~~~
468 492
469 493 You can even embed an entire page from another site in an iframe; for
470 494 example this is today's Wikipedia page for mobile users:
471 495
472 496 In[9]:
473 497
474 498 .. code:: python
475 499
476 500 HTML('<iframe src=http://en.mobile.wikipedia.org/?useformat=mobile width=700 height=350></iframe>')
477 501
478 502 Out[9]:
503 .. parsed-literal::
504
505 <IPython.core.display.HTML at 0x1094900d0>
506
479 507
480 508 Mathematics
481 509 ~~~~~~~~~~~
482 510
483 511 And we also support the display of mathematical expressions typeset in
484 512 LaTeX, which is rendered in the browser thanks to the `MathJax
485 513 library <http://mathjax.org>`_.
486 514
487 515 Note that this is *different* from the above examples. Above we were
488 516 typing mathematical expressions in Markdown cells (along with normal
489 517 text) and letting the browser render them; now we are displaying the
490 518 output of a Python computation as a LaTeX expression wrapped by the
491 519 ``Math()`` object so the browser renders it. The ``Math`` object will
492 520 add the needed LaTeX delimiters (``$$``) if they are not provided:
493 521
494 522 In[10]:
495 523
496 524 .. code:: python
497 525
498 526 from IPython.display import Math
499 527 Math(r'F(k) = \int_{-\infty}^{\infty} f(x) e^{2\pi i k} dx')
500 528
501 529 Out[10]:
502 530 .. math::
503 531
504 532 $$F(k) = \int_{-\infty}^{\infty} f(x) e^{2\pi i k} dx$$
505 533
506 534
507 535 With the ``Latex`` class, you have to include the delimiters yourself.
508 536 This allows you to use other LaTeX modes such as ``eqnarray``:
509 537
510 538 In[11]:
511 539
512 540 .. code:: python
513 541
514 542 from IPython.display import Latex
515 543 Latex(r"""\begin{eqnarray}
516 544 \nabla \times \vec{\mathbf{B}} -\, \frac1c\, \frac{\partial\vec{\mathbf{E}}}{\partial t} & = \frac{4\pi}{c}\vec{\mathbf{j}} \\
517 545 \nabla \cdot \vec{\mathbf{E}} & = 4 \pi \rho \\
518 546 \nabla \times \vec{\mathbf{E}}\, +\, \frac1c\, \frac{\partial\vec{\mathbf{B}}}{\partial t} & = \vec{\mathbf{0}} \\
519 547 \nabla \cdot \vec{\mathbf{B}} & = 0
520 548 \end{eqnarray}""")
521 549
522 550 Out[11]:
523 551 .. math::
524 552
525 553 \begin{eqnarray}
526 554 \nabla \times \vec{\mathbf{B}} -\, \frac1c\, \frac{\partial\vec{\mathbf{E}}}{\partial t} & = \frac{4\pi}{c}\vec{\mathbf{j}} \\
527 555 \nabla \cdot \vec{\mathbf{E}} & = 4 \pi \rho \\
528 556 \nabla \times \vec{\mathbf{E}}\, +\, \frac1c\, \frac{\partial\vec{\mathbf{B}}}{\partial t} & = \vec{\mathbf{0}} \\
529 557 \nabla \cdot \vec{\mathbf{B}} & = 0
530 558 \end{eqnarray}
531 559
532 560
533 561 Or you can enter latex directly with the ``%%latex`` cell magic:
534 562
535 563 In[12]:
536 564
537 565 .. code:: python
538 566
539 567 %%latex
540 568 \begin{aligned}
541 569 \nabla \times \vec{\mathbf{B}} -\, \frac1c\, \frac{\partial\vec{\mathbf{E}}}{\partial t} & = \frac{4\pi}{c}\vec{\mathbf{j}} \\
542 570 \nabla \cdot \vec{\mathbf{E}} & = 4 \pi \rho \\
543 571 \nabla \times \vec{\mathbf{E}}\, +\, \frac1c\, \frac{\partial\vec{\mathbf{B}}}{\partial t} & = \vec{\mathbf{0}} \\
544 572 \nabla \cdot \vec{\mathbf{B}} & = 0
545 573 \end{aligned}
546 574
547 575 .. math::
548 576
549 577 \begin{aligned}
550 578 \nabla \times \vec{\mathbf{B}} -\, \frac1c\, \frac{\partial\vec{\mathbf{E}}}{\partial t} & = \frac{4\pi}{c}\vec{\mathbf{j}} \\
551 579 \nabla \cdot \vec{\mathbf{E}} & = 4 \pi \rho \\
552 580 \nabla \times \vec{\mathbf{E}}\, +\, \frac1c\, \frac{\partial\vec{\mathbf{B}}}{\partial t} & = \vec{\mathbf{0}} \\
553 581 \nabla \cdot \vec{\mathbf{B}} & = 0
554 582 \end{aligned}
555 583
556 584 There is also a ``%%javascript`` cell magic for running javascript
557 585 directly, and ``%%svg`` for manually entering SVG content.
558 586
559 587 Loading external codes
560 588 ======================
561 589
562 590 - Drag and drop a ``.py`` in the dashboard
563 591 - Use ``%load`` with any local or remote url: `the Matplotlib
564 592 Gallery! <http://matplotlib.sourceforge.net/gallery.html>`_
565 593
566 594 In this notebook we've kept the output saved so you can see the result,
567 595 but you should run the next cell yourself (with an active internet
568 596 connection).
569 597
570 598 Let's make sure we have pylab again, in case we have restarted the
571 599 kernel due to the crash demo above
572 600
573 601 In[12]:
574 602
575 603 .. code:: python
576 604
577 605 %pylab inline
578 606
579 607
580 608 .. parsed-literal::
581 609
582 610
583 611 Welcome to pylab, a matplotlib-based Python environment [backend: module://IPython.zmq.pylab.backend_inline].
584 612 For more information, type 'help(pylab)'.
585 613
586 614 In[15]:
587 615
588 616 .. code:: python
589 617
590 618 %load http://matplotlib.sourceforge.net/mpl_examples/pylab_examples/integral_demo.py
591 619
592 620 In[16]:
593 621
594 622 .. code:: python
595 623
596 624 #!/usr/bin/env python
597 625
598 626 # implement the example graphs/integral from pyx
599 627 from pylab import *
600 628 from matplotlib.patches import Polygon
601 629
602 630 def func(x):
603 631 return (x-3)*(x-5)*(x-7)+85
604 632
605 633 ax = subplot(111)
606 634
607 635 a, b = 2, 9 # integral area
608 636 x = arange(0, 10, 0.01)
609 637 y = func(x)
610 638 plot(x, y, linewidth=1)
611 639
612 640 # make the shaded region
613 641 ix = arange(a, b, 0.01)
614 642 iy = func(ix)
615 643 verts = [(a,0)] + zip(ix,iy) + [(b,0)]
616 644 poly = Polygon(verts, facecolor='0.8', edgecolor='k')
617 645 ax.add_patch(poly)
618 646
619 647 text(0.5 * (a + b), 30,
620 648 r"$\int_a^b f(x)\mathrm{d}x$", horizontalalignment='center',
621 649 fontsize=20)
622 650
623 651 axis([0,10, 0, 180])
624 652 figtext(0.9, 0.05, 'x')
625 653 figtext(0.1, 0.9, 'y')
626 654 ax.set_xticks((a,b))
627 655 ax.set_xticklabels(('a','b'))
628 656 ax.set_yticks([])
629 657 show()
630 658
631 659
632 660 .. image:: _fig_60.png
633
General Comments 0
You need to be logged in to leave comments. Login now