Skip to content

Commit 38e2714

Browse files
committed
fixed bug 1202831
svn path=/trunk/matplotlib/; revision=1534
1 parent 0d16c5c commit 38e2714

File tree

9 files changed

+74
-32
lines changed

9 files changed

+74
-32
lines changed

API_CHANGES

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,15 @@
1+
12
API Changes in matplotlib-0.82.1
23

4+
backends/__init__.py no longer imports new_figure_manager,
5+
draw_if_interactive and show from the default backend, but puts
6+
these imports into a call to pylab_setup. Also, the Toolbar is no
7+
longer imported from WX/WXAgg. New usage
8+
9+
from backends import pylab_setup
10+
new_figure_manager, draw_if_interactive, show = pylab_setup()
11+
12+
313
Moved Figure.get_width_height() to FigureCanvasBase. It now returns
414
int instead of float.
515

CHANGELOG

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,16 @@
11
New entries should be added at the top
22

3+
4+
2005-07-05 Fixed default backend import problem when using API (SF bug
5+
# 1209354 - see API_CHANGES for more info - JDH
6+
7+
38
2005-07-04 backend_gtk.py: require PyGTK version 2.0.0 or higher - SC
49

510
2005-06-30 setupext.py: added numarray_inc_dirs for building against
611
numarray when not installed in standard location - ADS
712

13+
814
2005-06-27 backend_svg.py: write figure width, height as int, not float.
915
Update to fix some of the pychecker warnings - SC
1016

TODO

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -707,5 +707,6 @@ ZeroDivisionError: SeparableTransformation::eval_scalars yin interval is zero; c
707707

708708
-- clipping off in date_demo_rrule (agg 0.5 offset bug?)
709709

710-
-- merge qt patch.
710+
-- DONE merge qt patch.
711711

712+
-- add frac kwarg to

examples/webapp_demo.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -61,9 +61,9 @@ def make_fig():
6161
line, = ax.plot([1,2,3], 'ro--', markersize=12, markerfacecolor='g')
6262

6363
# make a translucent scatter collection
64-
x = nx.rand(100)
65-
y = nx.rand(100)
66-
area = nx.pi*(10 * nx.rand(100))**2 # 0 to 10 point radiuses
64+
x = nx.mlab.rand(100)
65+
y = nx.mlab.rand(100)
66+
area = nx.pi*(10 * nx.mlab.rand(100))**2 # 0 to 10 point radiuses
6767
c = ax.scatter(x,y,area)
6868
c.set_alpha(0.5)
6969

lib/matplotlib/axes.py

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -749,7 +749,11 @@ def _get_verts_in_data_coords(self, trans, xys):
749749
return [ self.transData.inverse_xy_tup(xy) for xy in xys]
750750

751751
def add_patch(self, p):
752-
'Add a line to the list of plot lines'
752+
"""
753+
Add a patch to the list of Axes patches; the clipbox will be
754+
set to the Axes clipping box. If the transform is not set, it
755+
wil be set to self.transData.
756+
"""
753757
self._set_artist_props(p)
754758
p.set_clip_box(self.bbox)
755759
xys = self._get_verts_in_data_coords(
@@ -1463,7 +1467,19 @@ def errorbar(self, x, y, yerr=None, xerr=None,
14631467
barsabove, if True, will plot the errorbars above the plot symbols
14641468
- default is below
14651469
1466-
kwargs are passed on to the plot command for the markers
1470+
kwargs are passed on to the plot command for the markers.
1471+
So you can add additional key=value pairs to control the
1472+
errorbar markers. For example, this code makes big red
1473+
squares with thick green edges
1474+
1475+
>>> x,y,yerr = rand(3,10)
1476+
>>> errorbar(x, y, yerr, marker='s',
1477+
mfc='red', mec='green', ms=20, mew=4)
1478+
1479+
mfc, mec, ms and mew are aliases for the longer property
1480+
names, markerfacecolor, markeredgecolor, markersize and
1481+
markeredgewith.
1482+
14671483
14681484
Return value is a length 2 tuple. The first element is a list of
14691485
y symbol lines. The second element is a list of error bar lines.

lib/matplotlib/backends/__init__.py

Lines changed: 29 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -9,36 +9,43 @@
99
non_interactive_bk = ['Agg2', 'Agg','Cairo','GD','GDK','Paint','PS', 'LaTeX', 'SVG','Template']
1010
all_backends = interactive_bk + non_interactive_bk
1111

12+
1213
backend = matplotlib.get_backend()
1314
if backend not in all_backends:
1415
raise ValueError, 'Unrecognized backend %s' % backend
1516

16-
# Import the requested backend into a generic module object
17-
backend_name = 'backend_'+backend.lower()
18-
backend_mod = __import__('matplotlib.backends.'+backend_name,
19-
globals(),locals(),[backend_name])
2017

21-
# Things we pull in from all backends
22-
new_figure_manager = backend_mod.new_figure_manager
18+
def pylab_setup():
19+
'return new_figure_manager, draw_if_interactive and show for pylab'
20+
# Import the requested backend into a generic module object
21+
backend_name = 'backend_'+backend.lower()
22+
backend_mod = __import__('matplotlib.backends.'+backend_name,
23+
globals(),locals(),[backend_name])
24+
25+
# Things we pull in from all backends
26+
new_figure_manager = backend_mod.new_figure_manager
27+
28+
if hasattr(backend_mod,'backend_version'):
29+
backend_version = getattr(backend_mod,'backend_version')
30+
else: backend_version = 'unknown'
31+
2332

24-
if hasattr(backend_mod,'backend_version'):
25-
backend_version = getattr(backend_mod,'backend_version')
26-
else: backend_version = 'unknown'
2733

34+
# Now define the public API according to the kind of backend in use
35+
if backend in interactive_bk:
36+
show = backend_mod.show
37+
draw_if_interactive = backend_mod.draw_if_interactive
38+
else: # non-interactive backends
39+
def draw_if_interactive(): pass
40+
def show(): pass
2841

42+
# Additional imports which only happen for certain backends. This section
43+
# should probably disappear once all backends are uniform.
44+
if backend in ['WX','WXAgg']:
45+
Toolbar = backend_mod.Toolbar
46+
__all__.append('Toolbar')
2947

30-
# Now define the public API according to the kind of backend in use
31-
if backend in interactive_bk:
32-
show = backend_mod.show
33-
draw_if_interactive = backend_mod.draw_if_interactive
34-
else: # non-interactive backends
35-
def draw_if_interactive(): pass
36-
def show(): pass
48+
matplotlib.verbose.report('backend %s version %s' % (backend,backend_version))
49+
return new_figure_manager, draw_if_interactive, show
3750

38-
# Additional imports which only happen for certain backends. This section
39-
# should probably disappear once all backends are uniform.
40-
if backend in ['WX','WXAgg']:
41-
Toolbar = backend_mod.Toolbar
42-
__all__.append('Toolbar')
4351

44-
matplotlib.verbose.report('backend %s version %s' % (backend,backend_version))

lib/matplotlib/patches.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ def __init__(self,
3939

4040

4141
if len(kwargs): setp(self, **kwargs)
42+
4243
def update_from(self, other):
4344
Artist.update_from(self, other)
4445
self.set_edgecolor(other.get_edgecolor())

lib/matplotlib/pylab.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -197,7 +197,7 @@
197197

198198
from axes import Axes, PolarAxes
199199
import backends
200-
from backends import new_figure_manager, draw_if_interactive, show
200+
from backends import pylab_setup
201201

202202
from cbook import flatten, is_string_like, exception_to_str, popd, \
203203
silent_list, iterable, enumerate
@@ -211,7 +211,7 @@
211211
from artist import setp as _setp
212212

213213

214-
214+
new_figure_manager, draw_if_interactive, show = pylab_setup()
215215

216216
from image import imread as _imread
217217
from lines import Line2D

lib/matplotlib/widgets.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -266,11 +266,12 @@ def __init__(self, ax, labels, actives):
266266
ax.set_navigate(False)
267267

268268
if len(labels)>1:
269-
ys = linspace(1-dy, dy, len(labels))
270269
dy = 1./(len(labels)+1)
270+
ys = linspace(1-dy, dy, len(labels))
271271
else:
272-
ys = [0.5]
273272
dy = 0.25
273+
ys = [0.5]
274+
274275
cnt = 0
275276
axcolor = ax.get_axis_bgcolor()
276277

0 commit comments

Comments
 (0)