Skip to content

Commit 4dfcbf0

Browse files
committed
Merge pull request matplotlib#4777 from ericmjl/mep12-pythonic_matplotlib.py
mep12 on pythonic_matplotlib.py
2 parents 292a40b + f082fdb commit 4dfcbf0

File tree

1 file changed

+8
-9
lines changed

1 file changed

+8
-9
lines changed

examples/pylab_examples/pythonic_matplotlib.py

+8-9
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,10 @@
1-
#!/usr/bin/env python
21
"""
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
54
you how.
65
76
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
98
show commands. These hide a lot of complexity from you that you don't
109
need to see in normal figure creation, like instantiating DPI
1110
instances, managing the bounding boxes of the figure elements,
@@ -21,19 +20,19 @@
2120
If you are a web application developer, you may want to use the
2221
example in webapp_demo.py, which shows how to use the backend agg
2322
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
2625
application developers, however.
2726
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,
2928
and you want to emulate that using the true python method calls, there
3029
is an easy mapping. Many of those examples use 'set' to control
3130
figure properties. Here's how to map those commands onto instance
3231
methods
3332
3433
The syntax of set is
3534
36-
setp(object or sequence, somestring, attribute)
35+
plt.setp(object or sequence, somestring, attribute)
3736
3837
if called with an object, set calls
3938
@@ -53,7 +52,7 @@
5352
"""
5453

5554

56-
from pylab import figure, show
55+
from matplotlib.pyplot import figure, show
5756
from numpy import arange, sin, pi
5857

5958
t = arange(0.0, 1.0, 0.01)

0 commit comments

Comments
 (0)