Skip to content

Commit 3a301cd

Browse files
committed
Jochen's ps patch
svn path=/trunk/matplotlib/; revision=602
1 parent e42a4f5 commit 3a301cd

File tree

5 files changed

+76
-169
lines changed

5 files changed

+76
-169
lines changed

Makefile

-131
Original file line numberDiff line numberDiff line change
@@ -1,127 +1,4 @@
11
# Makefile for matplotlib
2-
# Copyright (C) 2003 <jdhunter@ace.bsd.uchicago.edu>
3-
# $Header$
4-
# $Log$
5-
# Revision 1.40 2004/09/28 18:23:36 jdh2358
6-
# memleak tests
7-
#
8-
# Revision 1.39 2004/09/24 15:24:31 jdh2358
9-
# reorganizes py code
10-
#
11-
# Revision 1.38 2004/08/05 15:20:53 jdh2358
12-
# some htdocs fixes
13-
#
14-
# Revision 1.37 2004/07/27 16:46:42 jdh2358
15-
# axes connection fix
16-
#
17-
# Revision 1.36 2004/07/09 16:27:34 jdh2358
18-
# make clean purges svg
19-
#
20-
# Revision 1.35 2004/06/15 17:29:53 jdh2358
21-
# fixed bad scaling with singleton plots
22-
#
23-
# Revision 1.34 2004/06/09 13:47:55 jdh2358
24-
# added CXX ft2font
25-
#
26-
# Revision 1.33 2004/05/19 19:55:18 jdh2358
27-
# sync to 0.54
28-
#
29-
# Revision 1.32 2004/05/17 15:08:44 jdh2358
30-
# updated goals and what's new
31-
#
32-
# Revision 1.31 2004/05/04 20:39:16 jdh2358
33-
# fixed makefile and some text bugs
34-
#
35-
# Revision 1.30 2004/04/26 19:41:47 barrett
36-
# Added a line to the htmldocs section to create the license.html.template file with the appropriate version number.
37-
#
38-
# Revision 1.29 2004/04/21 15:28:55 jdh2358
39-
# sync to 0.53
40-
#
41-
# Revision 1.28 2004/04/20 22:53:37 jdh2358
42-
# removed tz info from dates; updated htdocs
43-
#
44-
# Revision 1.27 2004/04/20 11:32:35 jdh2358
45-
# added finance module
46-
#
47-
# Revision 1.26 2004/03/16 20:26:36 jdh2358
48-
# sync to 0.52 release
49-
#
50-
# Revision 1.25 2004/03/15 14:49:46 jdh2358
51-
# updated image to work with data coords; moved image extendsion to _image
52-
#
53-
# Revision 1.24 2004/03/08 14:56:44 jdh2358
54-
# fixed subplot bug
55-
#
56-
# Revision 1.23 2004/02/27 14:47:46 jdh2358
57-
# added matplotlibrc and tk win32 compile fixes
58-
#
59-
# Revision 1.22 2004/02/18 18:11:24 jdh2358
60-
# updated setepext to work with darwin
61-
#
62-
# Revision 1.21 2004/02/17 15:10:43 jdh2358
63-
# updating to 0.50
64-
#
65-
# Revision 1.20 2004/02/16 18:04:55 jdh2358
66-
# fexed wx to work on windows and linux
67-
#
68-
# Revision 1.19 2004/02/11 19:16:01 jdh2358
69-
# reorganized table
70-
#
71-
# Revision 1.18 2004/02/11 00:07:44 jdh2358
72-
# relocated gtkgd ext mod
73-
#
74-
# Revision 1.17 2004/01/30 21:33:19 jdh2358
75-
# last changes for 0.50e
76-
#
77-
# Revision 1.16 2004/01/30 19:58:53 jdh2358
78-
# update...
79-
#
80-
# Revision 1.15 2004/01/30 18:20:55 jdh2358
81-
# renamed backend_gtk2 to backend_gtkgd
82-
#
83-
# Revision 1.14 2004/01/29 19:26:46 jdh2358
84-
# added API_CHANGES to htdocs
85-
#
86-
# Revision 1.13 2004/01/27 16:18:08 jdh2358
87-
# updated README and INSTALL
88-
#
89-
# Revision 1.12 2004/01/26 18:27:46 jdh2358
90-
# more ps and text API fixes
91-
#
92-
# Revision 1.11 2003/11/19 16:45:09 jdh2358
93-
# updated plotting commands list
94-
#
95-
# Revision 1.10 2003/11/14 00:07:29 jdh2358
96-
# added log transforms to new API
97-
#
98-
# Revision 1.9 2003/11/06 23:09:53 jdh2358
99-
# fixed some problems with the file release system
100-
#
101-
# Revision 1.8 2003/10/23 15:42:43 jdh2358
102-
# fixed figure text clip bug
103-
#
104-
# Revision 1.7 2003/10/18 17:54:26 jdh2358
105-
# fixed interactive2 and several small bugs
106-
#
107-
# Revision 1.6 2003/09/30 16:15:33 jdh2358
108-
# added legend
109-
#
110-
# Revision 1.5 2003/09/22 14:04:46 jdh2358
111-
# small bugfixes
112-
#
113-
# Revision 1.4 2003/09/15 17:54:16 jdh2358
114-
# multiple backed support take II
115-
#
116-
# Revision 1.3 2003/05/12 19:56:54 jdh2358
117-
# update license to version 2 and the docs
118-
#
119-
# Revision 1.2 2003/05/12 15:53:48 jdh2358
120-
# update matplotlib
121-
#
122-
# Revision 1.1 2003/05/12 15:50:11 jdh2358
123-
# adding Makefile, releases, docs
124-
#
1252

1263
PYTHON = /usr/local/bin/python2.3
1274
VERSION = `${PYTHON} setup.py --version`
@@ -149,14 +26,6 @@ release: ${DISTFILES}
14926
pyback:
15027
tar cvfz pyback.tar.gz *.py lib src examples/*.py unit/*.py
15128

152-
htmldocs:
153-
cp examples/*.py htdocs/examples;\
154-
cp -a .matplotlibrc INSTALL CHANGELOG NUMARRAY_ISSUES API_CHANGES lib/matplotlib htdocs/;\
155-
${PYTHON} license.py ${VERSION} htdocs/license.html.template;\
156-
cd htdocs;\
157-
${PYTHON} process_docs.py;\
158-
${PYTHON} convert.py;\
159-
tar cfz site.tar.gz *.html screenshots tut examples gd .matplotlibrc CHANGELOG NUMARRAY_ISSUES API_CHANGES;
16029

16130

16231

lib/matplotlib/backends/backend_ps.py

+9-12
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
from __future__ import division
77
from cStringIO import StringIO
88
import sys, os
9-
from matplotlib import verbose
9+
from matplotlib import verbose, __version__
1010
from matplotlib.afm import AFM
1111
from matplotlib.backend_bases import RendererBase, GraphicsContextBase,\
1212
FigureManagerBase, FigureCanvasBase
@@ -271,6 +271,7 @@ def get_ps(self):
271271

272272
def finish(self):
273273
self._pswriter.write('showpage\n')
274+
self._pswriter.write('%%EOF')
274275

275276
def new_gc(self):
276277
return GraphicsContextPS()
@@ -466,9 +467,9 @@ def print_figure(self, filename, dpi=72,
466467
lly = yo
467468
urx = llx + w
468469
ury = lly + h
469-
bboxstr = '%%BoundingBox: %d %d %d %d' % (llx, lly, urx, ury)
470+
bboxstr = '%%BoundingBox: %d %d %d %d' % (llx, lly, urx, ury)
470471

471-
pstype = 'PS-Adobe-2.0 EPSF-2.0'
472+
pstype = 'PS-Adobe-3.0 EPSF-3.0'
472473
else:
473474
pstype = 'PS'
474475
bboxstr = ''
@@ -496,14 +497,14 @@ def print_figure(self, filename, dpi=72,
496497
error_msg_ps('Could not open %s for writing' % filename)
497498
return
498499

499-
print >>fh, _psProlog % (pstype, bboxstr)
500+
print >>fh, _psProlog % (pstype, __version__, bboxstr)
500501
print >>fh, _psDefs
501502

502503
type42 = _type42 + [os.path.join(self.basepath, name) + '.ttf' \
503504
for name in bakoma_fonts]
504505
for font in type42:
505506
font = str(font) # todo: handle unicode filenames
506-
print >>fh, _psFonts % (os.path.basename(font),
507+
print >>fh, _psFonts % (FT2Font(font).postscript_name,
507508
encodeTTFasPS(font))
508509
print >>fh, renderer.get_ps()
509510

@@ -521,19 +522,15 @@ class FigureManagerPS(FigureManagerBase):
521522

522523
_psProlog = """\
523524
%%!%s
524-
%%%% Created by matplotlib http://matplotlib.sourceforge.net
525+
%%%%Creator: matplotlib version %s, http://matplotlib.sourceforge.net/
525526
%%%s
526527
%%%%EndComments
527-
528-
%%BeginProlog
529-
/inch {72 mul} def
530-
%%%%EndProlog
531528
"""
532529

533530
_psFonts = """\
534-
%%BeginFont: %s
531+
%%%%BeginFont: %s
535532
%s
536-
%%EndFont
533+
%%%%EndFont
537534
"""
538535

539536
_psDefs = """

lib/matplotlib/dates.py

+30-1
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@
8484

8585
from cbook import iterable
8686
from pytz import timezone
87-
from numerix import arange
87+
from numerix import arange, asarray
8888
from ticker import Formatter, Locator, Base
8989
from dateutil.rrule import rrule, MO, TU, WE, TH, FR, SA, SU, YEARLY,\
9090
MONTHLY, WEEKLY, DAILY, HOURLY, MINUTELY, SECONDLY
@@ -568,6 +568,34 @@ def _close_to_num(o1, o2, epsilon=5):
568568
delta = abs((o2-o1)*MUSECONDS_PER_DAY)
569569
assert(delta<epsilon)
570570

571+
def epoch2num(e):
572+
"""
573+
convert an epoch or sequence of epochs to the new date format,
574+
days since 0001
575+
"""
576+
spd = 24.*3600.
577+
return 719163 + asarray(e)/spd
578+
579+
def num2epoch(d):
580+
"""
581+
convert days since 0001 to epoch. d can be a number or sequence
582+
"""
583+
spd = 24.*3600.
584+
return (asarray(d)-719163)*spd
585+
586+
def mx2num(m):
587+
"""
588+
Convert mx datetime instance (or sequence of mx instances) to the
589+
new date format,
590+
"""
591+
scalar = False
592+
if not iterable(m):
593+
scalar = True
594+
m = [m]
595+
ret = epoch2num([m.ticks() for m in mxdates])
596+
if scalar: return ret[0]
597+
else: return ret
598+
571599
if __name__=='__main__':
572600

573601
#tz = None
@@ -621,3 +649,4 @@ def _close_to_num(o1, o2, epsilon=5):
621649
for t in dates: print formatter(t)
622650

623651

652+

lib/matplotlib/matlab.py

+36
Original file line numberDiff line numberDiff line change
@@ -319,6 +319,40 @@ def %s(*args, **kwargs):
319319
%s.__doc__ = Axes.%s.__doc__
320320
"""
321321

322+
def changed_name_function(f, newname):
323+
import new
324+
if matplotlib._python23:
325+
newf = new.function(f.func_code, f.func_globals, newname,
326+
f.func_defaults, f.func_closure)
327+
else:
328+
#if f.func_defaults is None:
329+
# argdefs = ()
330+
#else:
331+
argdefs = f.func_defaults
332+
newf = new.function(f.func_code, f.func_globals, newname,
333+
argdefs)
334+
335+
print f.func_defaults
336+
newf.__doc__ = f.__doc__
337+
return newf
338+
339+
def _wrap_axfunc(name):
340+
def wrapper(*args, **kwargs):
341+
try:
342+
func = getattr(gca(), name)
343+
ret = func(*args, **kwargs)
344+
except ValueError, msg:
345+
msg = raise_msg_to_str(msg)
346+
error_msg(msg)
347+
else:
348+
draw_if_interactive()
349+
return ret
350+
wrapper.__doc__ = getattr(Axes, name).__doc__
351+
#wrapper.__name__ = name
352+
return changed_name_function(wrapper, name)
353+
354+
355+
322356
# these methods are all simple wrappers of Axes methods by the same
323357
# name. We'll autogenerate these to avoid some of the boilerplate
324358
# using the fmt string above.
@@ -355,8 +389,10 @@ def %s(*args, **kwargs):
355389
)
356390

357391
for name in _methods:
392+
#locals[name] = _wrap_axfunc(name)
358393
exec(__fmt%(name, name, name, name))
359394

395+
#plot = _wrap_axfunc('plot')
360396

361397
def axis(*v):
362398
"""\

license.py

+1-25
Original file line numberDiff line numberDiff line change
@@ -5,22 +5,7 @@
55

66
version = sys.argv[1]
77

8-
if sys.argv[2] == 'htdocs/license.html.template':
9-
s = """\
10-
@header@
11-
12-
<h2>License</h2>
13-
14-
The matplotlib license is a shameless ripoff of the python license.<p>
15-
16-
<pre>
17-
18-
"""
19-
else:
20-
s = ""
21-
22-
23-
s += """\
8+
s = """\
249
LICENSE AGREEMENT FOR MATPLOTLIB %(version)s
2510
--------------------------------------
2611
@@ -72,15 +57,6 @@
7257
Agreement.
7358
""" % locals()
7459

75-
if sys.argv[2] == 'htdocs/license.html.template':
76-
s += """\
77-
78-
</pre>
79-
80-
@footer@
81-
"""
82-
else:
83-
pass
8460

8561
file(sys.argv[2], 'w').write(s)
8662

0 commit comments

Comments
 (0)