8000 refactored figure backend · matplotlib/matplotlib@4b6b9ab · GitHub
[go: up one dir, main page]

Skip to content

Commit 4b6b9ab

Browse files
committed
refactored figure backend
svn path=/trunk/matplotlib/; revision=111
1 parent 0744f73 commit 4b6b9ab

12 files changed

+56
-42
lines changed

API_CHANGES

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,10 @@
1+
API changes at 0.50
2+
3+
* refactored Figure class so it is no longer backend dependent.
4+
FigureManager takes over the backend specific duties of the
5+
Figure. matplotlib.backend_bases.FigureBase moved to
6+
matplotlib.figure.Figure
7+
18
API changes at 0.42
29

310
* Refactoring AxisText to be backend independent. Text drawing and

LICENSE

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
LICENSE AGREEMENT FOR MATPLOTLIB 0.42
1+
LICENSE AGREEMENT FOR MATPLOTLIB 0.42.2
22
--------------------------------------
33

44
1. This LICENSE AGREEMENT is between the John D. Hunter ("JDH"), and
@@ -9,30 +9,30 @@ documentation.
99
2. Subject to the terms and conditions of this License Agreement, JDH
1010
hereby grants Licensee a nonexclusive, royalty-free, world-wide
1111
license to reproduce, analyze, test, perform and/or display publicly,
12-
prepare derivative works, distribute, and otherwise use matplotlib 0.42
12+
prepare derivative works, distribute, and otherwise use matplotlib 0.42.2
1313
alone or in any derivative version, provided, however, that JDH's
1414
License Agreement and JDH's notice of copyright, i.e., "Copyright (c)
1515
2002, 2003 John D. Hunter; All Rights Reserved" are retained in
16-
matplotlib 0.42 alone or in any derivative version prepared by
16+
matplotlib 0.42.2 alone or in any derivative version prepared by
1717
Licensee.
1818

1919
3. In the event Licensee prepares a derivative work that is based on
20-
or incorporates matplotlib 0.42 or any part thereof, and wants to make
20+
or incorporates matplotlib 0.42.2 or any part thereof, and wants to make
2121
the derivative work available to others as provided herein, then
2222
Licensee hereby agrees to include in any such work a brief summary of
23-
the changes made to matplotlib 0.42.
23+
the changes made to matplotlib 0.42.2.
2424

25-
4. JDH is making matplotlib 0.42 available to Licensee on an "AS IS"
25+
4. JDH is making matplotlib 0.42.2 available to Licensee on an "AS IS"
2626
basis. JDH MAKES NO REPRESENTATIONS OR WARRANTIES, EXPRESS OR
2727
IMPLIED. BY WAY OF EXAMPLE, BUT NOT LIMITATION, JDH MAKES NO AND
2828
DISCLAIMS ANY REPRESENTATION OR WARRANTY OF MERCHANTABILITY OR FITNESS
29-
FOR ANY PARTICULAR PURPOSE OR THAT THE USE OF MATPLOTLIB 0.42 WILL NOT
29+
FOR ANY PARTICULAR PURPOSE OR THAT THE USE OF MATPLOTLIB 0.42.2 WILL NOT
3030
INFRINGE ANY THIRD PARTY RIGHTS.
3131

3232
5. JDH SHALL NOT BE LIABLE TO LICENSEE OR ANY OTHER USERS OF
33-
MATPLOTLIB 0.42 FOR ANY INCIDENTAL, SPECIAL, OR CONSEQUENTIAL DAMAGES
33+
MATPLOTLIB 0.42.2 FOR ANY INCIDENTAL, SPECIAL, OR CONSEQUENTIAL DAMAGES
3434
OR LOSS AS A RESULT OF MODIFYING, DISTRIBUTING, OR OTHERWISE USING
35-
MATPLOTLIB 0.42, OR ANY DERIVATIVE THEREOF, EVEN IF ADVISED OF THE
35+
MATPLOTLIB 0.42.2, OR ANY DERIVATIVE THEREOF, EVEN IF ADVISED OF THE
3636
POSSIBILITY THEREOF.
3737

3838
6. This License Agreement will automatically terminate upon a material
@@ -44,6 +44,6 @@ Licensee. This License Agreement does not grant permission to use JDH
4444
trademarks or trade name in a trademark sense to endorse or promote
4545
products or services of Licensee, or any third party.
4646

47-
8. By copying, installing or otherwise using matplotlib 0.42, Licensee
47+
8. By copying, installing or otherwise using matplotlib 0.42.2, Licensee
4848
agrees to be bound by the terms and conditions of this License
4949
Agreement.

MANIFEST

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@ examples/axes_demo.py
1818
examples/axes_props.py
1919
examples/barchart_demo.py
2020
examples/batch_test_gd.py
21-
examples/break.py
2221
examples/color_demo.py
2322
examples/csd_demo.py
2423
examples/data_helper.py
@@ -52,14 +51,11 @@ examples/pstest.py
5251
examples/scatter_demo.py
5352
examples/scatter_demo2.py
5453
examples/simple_plot.py
55-
examples/specgram_demo.py
5654
examples/stock_demo.py
5755
examples/subplot_demo.py
5856
examples/system_monitor.py
59-
examples/test.py
6057
examples/text_handles.py
6158
examples/text_themes.py
62-
examples/vline_demo.py
6359
examples/wx_demo.py
6460
examples/xvfb_demo.py
6561
examples/data/AAPL.dat

examples/csd_demo.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727
ylabel('s1 and s2')
2828

2929
subplot(212)
30-
cxy, f = cohere(s1, s2, 256, 1/dt)
30+
cxy, f = csd(s1, s2, 256, 1/dt)
3131
show()
3232

3333

examples/embedding_in_gtk.py

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,12 @@
1+
from Numeric import arange, sin, pi
2+
13
import matplotlib
24
matplotlib.use('GTK')
35

4-
from matplotlib.backends import Figure
56
from matplotlib.axes import Subplot
6-
import Numeric as numpy
7+
from matplotlib.backends.backend_gtk import FigureCanvasGTK
8+
from matplotlib.figure import Figure
9+
710
import gtk
811

912
win = gtk.Window()
@@ -17,13 +20,15 @@
1720

1821
f = Figure(figsize=(5,4), dpi=100)
1922
a = Subplot(f, 111)
20-
t = numpy.arange(0.0,3.0,0.01)
21-
s = numpy.sin(2*numpy.pi*t)
23+
t = arange(0.0,3.0,0.01)
24+
s = sin(2*pi*t)
2225

2326
a.plot(t,s)
2427
f.add_axis(a)
25-
f.show()
26-
vbox.pack_start(f)
28+
29+
canvas = FigureCanvasGTK(f) # a gtk.DrawingArea
30+
canvas.show()
31+
vbox.pack_start(canvas)
2732

2833
button = gtk.Button('Quit')
2934
button.connect('clicked', lambda b: gtk.mainquit())

examples/embedding_in_gtk2.py

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
1+
from Numeric import arange, sin, pi
2+
13
import matplotlib
24
matplotlib.use('GTK')
3-
4-
from matplotlib.backends.backend_gtk import Figure, NavigationToolbar
5+
from matplotlib.backends.backend_gtk import FigureCanvasGTK, NavigationToolbar
56

67
from matplotlib.axes import Subplot
7-
import Numeric as numpy
8+
from matplotlib.figure import Figure
89
import gtk
910

1011
win = gtk.Window()
@@ -18,15 +19,18 @@
1819

1920
fig = Figure(figsize=(5,4), dpi=100)
2021
ax = Subplot(fig, 111)
21-
t = numpy.arange(0.0,3.0,0.01)
22-
s = numpy.sin(2*numpy.pi*t)
22+
t = arange(0.0,3.0,0.01)
23+
s = sin(2*pi*t)
2324

2425
ax.plot(t,s)
2526
fig.add_axis(ax)
26-
fig.show()
27-
vbox.pack_start(fig)
2827

29-
toolbar = NavigationToolbar(fig, win)
28+
canvas = FigureCanvasGTK(fig) # a gtk.DrawingArea
29+
canvas.show()
30+
vbox.pack_start(canvas)
31+
32+
33+
toolbar = NavigationToolbar(canvas, win)
3034
toolbar.show()
3135
vbox.pack_start(toolbar, gtk.FALSE, gtk.FALSE)
3236

examples/mpl_with_glade.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,8 @@
11
import matplotlib
22
matplotlib.use('GTK')
33

4-
from matplotlib.backends import Figure
54
from matplotlib.axes import Subplot
6-
from matplotlib.backends.backend_gtk EED3 import NavigationToolbar
5+
from matplotlib.backends.backend_gtk import FigureGTK, NavigationToolbar
76

87
from Numeric import arange, sin, pi
98
import gtk
@@ -38,7 +37,7 @@ def __init__(self):
3837
self.widgets = gtk.glade.XML('mpl_with_glade.glade')
3938
self.widgets.signal_autoconnect(GladeHandlers.__dict__)
4039

41-
self.figure = Figure(figsize=(8,6), dpi=72)
40+
self.figure = FigureGTK(figsize=(8,6), dpi=72)
4241
self.figure.show()
4342
self.axis = Subplot(self.figure, 111)
4443
self.figure.add_axis(self.axis)
@@ -49,7 +48,8 @@ def __init__(self):
4948
self.axis.set_ylabel('voltage')
5049

5150
self['vboxMain'].pack_start(self.figure, gtk.TRUE, gtk.TRUE)
52-
51+
self['vboxMain'].show()
52+
5353
# below is optional if you want the navigation toolbar
5454
self.navToolbar = NavigationToolbar(self.figure, self['windowMain'])
5555
self.navToolbar.lastDir = '/var/tmp/'

examples/mri_with_eeg.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
# flip upside down
1717
im = array([im[i] for i in arange(255,-1,-1)])
1818

19-
if 1: # plot the MRI in pcolor
19+
if 0: # plot the MRI in pcolor
2020
subplot(221)
2121
pcolor(im, shading='flat')
2222
axis('off')
@@ -41,7 +41,7 @@
4141
ticklocs = []
4242
ax = subplot(212)
4343
for i in range(numRows):
44-
thisLine = Line2D(ax.dpi, ax.bbox, t, data[:,i],
44+
thisLine = Line2D(ax.dpi, ax.bbox, t, data[:,i]-data[0,i],
4545
transx=ax.xaxis.transData, transy=ax.yaxis.transData)
4646
thisLine.set_vertical_offset(3*i)
4747
ax.add_line(thisLine)
@@ -50,7 +50,7 @@
5050
set(gca(), 'xticks', arange(10))
5151
set(gca(), 'yticks', ticklocs)
5252
set(gca(), 'yticklabels', ['PG3', 'PG5', 'PG7', 'PG9'])
53-
set(gca(), 'ylim', [-3, 12])
53+
#set(gca(), 'ylim', [0, 20])
5454
xlabel('time (s)')
5555

5656

examples/simple_plot.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
from matplotlib.matlab import *
22

3-
t = arange(0.0, 2.0, 0.01)
4-
s = sin(2*pi*t)
3+
t = arange(0.0, 1.0, 0.002)
4+
s = sin(2*2*pi*t)
55
l = plot(t, s)
66

77
xlabel('time (s)')
@@ -11,5 +11,5 @@
1111

1212
#grid(True)
1313
#set(gca(), 'xticks', (0,.2,.7))
14-
#savefig('test2')
14+
savefig('test2')
1515
show()

examples/subplot_demo.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,14 +11,16 @@ def f(t):
1111

1212
subplot(211)
1313
plot(t1, f(t1), 'bo', t2, f(t2), 'k')
14+
grid(True)
1415
title('A tale of 2 subplots')
1516
ylabel('Damped oscillation')
1617

1718
subplot(212)
1819
plot(t3, cos(2*pi*t3), 'r--')
20+
grid(True)
1921
xlabel('time (s)')
2022
ylabel('Undamped')
2123

22-
#savefig('subplot_demo.eps')
24+
savefig('subplot_demo',dpi=300)
2325
show()
2426

examples/text_themes.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,5 +19,5 @@ def f(t):
1919
xlabel('time (s)', font)
2020
ylabel('voltage (mV)', font)
2121

22-
#savefig('text_themes')
22+
savefig('text_themes')
2323
show()

setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
data.extend(glob.glob('images/*.xpm'))
1010

1111
setup(name="matplotlib",
12-
version= '0.42',
12+
version= '0.42.2',
1313
description = "Matlab style python plotting package",
1414
author = "John D. Hunter",
1515
author_email="jdhunter@ace.bsd.uchicago.edu",

0 commit comments

Comments
 (0)
0