|
1 | | -#!/usr/bin/env python |
2 | 1 | """ |
3 | | -Some people prefer to write more pythonic, object oriented, code |
4 | | -rather than use the pylab interface to matplotlib. This example shows |
| 2 | +Some people prefer to write more pythonic, object-oriented code |
| 3 | +rather than use the pyplot interface to matplotlib. This example shows |
5 | 4 | you how. |
6 | 5 |
|
7 | 6 | Unless you are an application developer, I recommend using part of the |
8 | | -pylab interface, particularly the figure, close, subplot, axes, and |
| 7 | +pyplot interface, particularly the figure, close, subplot, axes, and |
9 | 8 | show commands. These hide a lot of complexity from you that you don't |
10 | 9 | need to see in normal figure creation, like instantiating DPI |
11 | 10 | instances, managing the bounding boxes of the figure elements, |
|
21 | 20 | If you are a web application developer, you may want to use the |
22 | 21 | example in webapp_demo.py, which shows how to use the backend agg |
23 | 22 | figure canvase directly, with none of the globals (current figure, |
24 | | -current axes) that are present in the pylab interface. Note that |
25 | | -there is no reason why the pylab interface won't work for web |
| 23 | +current axes) that are present in the pyplot interface. Note that |
| 24 | +there is no reason why the pyplot interface won't work for web |
26 | 25 | application developers, however. |
27 | 26 |
|
28 | | -If you see an example in the examples dir written in pylab interface, |
| 27 | +If you see an example in the examples dir written in pyplot interface, |
29 | 28 | and you want to emulate that using the true python method calls, there |
30 | 29 | is an easy mapping. Many of those examples use 'set' to control |
31 | 30 | figure properties. Here's how to map those commands onto instance |
32 | 31 | methods |
33 | 32 |
|
34 | 33 | The syntax of set is |
35 | 34 |
|
36 | | - setp(object or sequence, somestring, attribute) |
| 35 | + plt.setp(object or sequence, somestring, attribute) |
37 | 36 |
|
38 | 37 | if called with an object, set calls |
39 | 38 |
|
|
53 | 52 | """ |
54 | 53 |
|
55 | 54 |
|
56 | | -from pylab import figure, show |
| 55 | +from matplotlib.pyplot import figure, show |
57 | 56 | from numpy import arange, sin, pi |
58 | 57 |
|
59 | 58 | t = arange(0.0, 1.0, 0.01) |
|
0 commit comments