Skip to content
Browse files

Jochen's ps patch

svn path=/trunk/matplotlib/; revision=602
  • Loading branch information...
1 parent e42a4f5 commit 3a301cd86484e2479a1acb173908789c77ea7ca6 @jdh2358 jdh2358 committed
Showing with 76 additions and 169 deletions.
  1. +0 −131 Makefile
  2. +9 −12 lib/matplotlib/backends/backend_ps.py
  3. +30 −1 lib/matplotlib/dates.py
  4. +36 −0 lib/matplotlib/matlab.py
  5. +1 −25 license.py
View
131 Makefile
@@ -1,127 +1,4 @@
# Makefile for matplotlib
-# Copyright (C) 2003 <jdhunter@ace.bsd.uchicago.edu>
-# $Header$
-# $Log$
-# Revision 1.40 2004/09/28 18:23:36 jdh2358
-# memleak tests
-#
-# Revision 1.39 2004/09/24 15:24:31 jdh2358
-# reorganizes py code
-#
-# Revision 1.38 2004/08/05 15:20:53 jdh2358
-# some htdocs fixes
-#
-# Revision 1.37 2004/07/27 16:46:42 jdh2358
-# axes connection fix
-#
-# Revision 1.36 2004/07/09 16:27:34 jdh2358
-# make clean purges svg
-#
-# Revision 1.35 2004/06/15 17:29:53 jdh2358
-# fixed bad scaling with singleton plots
-#
-# Revision 1.34 2004/06/09 13:47:55 jdh2358
-# added CXX ft2font
-#
-# Revision 1.33 2004/05/19 19:55:18 jdh2358
-# sync to 0.54
-#
-# Revision 1.32 2004/05/17 15:08:44 jdh2358
-# updated goals and what's new
-#
-# Revision 1.31 2004/05/04 20:39:16 jdh2358
-# fixed makefile and some text bugs
-#
-# Revision 1.30 2004/04/26 19:41:47 barrett
-# Added a line to the htmldocs section to create the license.html.template file with the appropriate version number.
-#
-# Revision 1.29 2004/04/21 15:28:55 jdh2358
-# sync to 0.53
-#
-# Revision 1.28 2004/04/20 22:53:37 jdh2358
-# removed tz info from dates; updated htdocs
-#
-# Revision 1.27 2004/04/20 11:32:35 jdh2358
-# added finance module
-#
-# Revision 1.26 2004/03/16 20:26:36 jdh2358
-# sync to 0.52 release
-#
-# Revision 1.25 2004/03/15 14:49:46 jdh2358
-# updated image to work with data coords; moved image extendsion to _image
-#
-# Revision 1.24 2004/03/08 14:56:44 jdh2358
-# fixed subplot bug
-#
-# Revision 1.23 2004/02/27 14:47:46 jdh2358
-# added matplotlibrc and tk win32 compile fixes
-#
-# Revision 1.22 2004/02/18 18:11:24 jdh2358
-# updated setepext to work with darwin
-#
-# Revision 1.21 2004/02/17 15:10:43 jdh2358
-# updating to 0.50
-#
-# Revision 1.20 2004/02/16 18:04:55 jdh2358
-# fexed wx to work on windows and linux
-#
-# Revision 1.19 2004/02/11 19:16:01 jdh2358
-# reorganized table
-#
-# Revision 1.18 2004/02/11 00:07:44 jdh2358
-# relocated gtkgd ext mod
-#
-# Revision 1.17 2004/01/30 21:33:19 jdh2358
-# last changes for 0.50e
-#
-# Revision 1.16 2004/01/30 19:58:53 jdh2358
-# update...
-#
-# Revision 1.15 2004/01/30 18:20:55 jdh2358
-# renamed backend_gtk2 to backend_gtkgd
-#
-# Revision 1.14 2004/01/29 19:26:46 jdh2358
-# added API_CHANGES to htdocs
-#
-# Revision 1.13 2004/01/27 16:18:08 jdh2358
-# updated README and INSTALL
-#
-# Revision 1.12 2004/01/26 18:27:46 jdh2358
-# more ps and text API fixes
-#
-# Revision 1.11 2003/11/19 16:45:09 jdh2358
-# updated plotting commands list
-#
-# Revision 1.10 2003/11/14 00:07:29 jdh2358
-# added log transforms to new API
-#
-# Revision 1.9 2003/11/06 23:09:53 jdh2358
-# fixed some problems with the file release system
-#
-# Revision 1.8 2003/10/23 15:42:43 jdh2358
-# fixed figure text clip bug
-#
-# Revision 1.7 2003/10/18 17:54:26 jdh2358
-# fixed interactive2 and several small bugs
-#
-# Revision 1.6 2003/09/30 16:15:33 jdh2358
-# added legend
-#
-# Revision 1.5 2003/09/22 14:04:46 jdh2358
-# small bugfixes
-#
-# Revision 1.4 2003/09/15 17:54:16 jdh2358
-# multiple backed support take II
-#
-# Revision 1.3 2003/05/12 19:56:54 jdh2358
-# update license to version 2 and the docs
-#
-# Revision 1.2 2003/05/12 15:53:48 jdh2358
-# update matplotlib
-#
-# Revision 1.1 2003/05/12 15:50:11 jdh2358
-# adding Makefile, releases, docs
-#
PYTHON = /usr/local/bin/python2.3
VERSION = `${PYTHON} setup.py --version`
@@ -149,14 +26,6 @@ release: ${DISTFILES}
pyback:
tar cvfz pyback.tar.gz *.py lib src examples/*.py unit/*.py
-htmldocs:
- cp examples/*.py htdocs/examples;\
- cp -a .matplotlibrc INSTALL CHANGELOG NUMARRAY_ISSUES API_CHANGES lib/matplotlib htdocs/;\
- ${PYTHON} license.py ${VERSION} htdocs/license.html.template;\
- cd htdocs;\
- ${PYTHON} process_docs.py;\
- ${PYTHON} convert.py;\
- tar cfz site.tar.gz *.html screenshots tut examples gd .matplotlibrc CHANGELOG NUMARRAY_ISSUES API_CHANGES;
View
21 lib/matplotlib/backends/backend_ps.py
@@ -6,7 +6,7 @@
from __future__ import division
from cStringIO import StringIO
import sys, os
-from matplotlib import verbose
+from matplotlib import verbose, __version__
from matplotlib.afm import AFM
from matplotlib.backend_bases import RendererBase, GraphicsContextBase,\
FigureManagerBase, FigureCanvasBase
@@ -271,6 +271,7 @@ def get_ps(self):
def finish(self):
self._pswriter.write('showpage\n')
+ self._pswriter.write('%%EOF')
def new_gc(self):
return GraphicsContextPS()
@@ -466,9 +467,9 @@ def print_figure(self, filename, dpi=72,
lly = yo
urx = llx + w
ury = lly + h
- bboxstr = '%%BoundingBox: %d %d %d %d' % (llx, lly, urx, ury)
+ bboxstr = '%%BoundingBox: %d %d %d %d' % (llx, lly, urx, ury)
- pstype = 'PS-Adobe-2.0 EPSF-2.0'
+ pstype = 'PS-Adobe-3.0 EPSF-3.0'
else:
pstype = 'PS'
bboxstr = ''
@@ -496,14 +497,14 @@ def print_figure(self, filename, dpi=72,
error_msg_ps('Could not open %s for writing' % filename)
return
- print >>fh, _psProlog % (pstype, bboxstr)
+ print >>fh, _psProlog % (pstype, __version__, bboxstr)
print >>fh, _psDefs
type42 = _type42 + [os.path.join(self.basepath, name) + '.ttf' \
for name in bakoma_fonts]
for font in type42:
font = str(font) # todo: handle unicode filenames
- print >>fh, _psFonts % (os.path.basename(font),
+ print >>fh, _psFonts % (FT2Font(font).postscript_name,
encodeTTFasPS(font))
print >>fh, renderer.get_ps()
@@ -521,19 +522,15 @@ class FigureManagerPS(FigureManagerBase):
_psProlog = """\
%%!%s
-%%%% Created by matplotlib http://matplotlib.sourceforge.net
+%%%%Creator: matplotlib version %s, http://matplotlib.sourceforge.net/
%%%s
%%%%EndComments
-
-%%BeginProlog
-/inch {72 mul} def
-%%%%EndProlog
"""
_psFonts = """\
-%%BeginFont: %s
+%%%%BeginFont: %s
%s
-%%EndFont
+%%%%EndFont
"""
_psDefs = """
View
31 lib/matplotlib/dates.py
@@ -84,7 +84,7 @@
from cbook import iterable
from pytz import timezone
-from numerix import arange
+from numerix import arange, asarray
from ticker import Formatter, Locator, Base
from dateutil.rrule import rrule, MO, TU, WE, TH, FR, SA, SU, YEARLY,\
MONTHLY, WEEKLY, DAILY, HOURLY, MINUTELY, SECONDLY
@@ -568,6 +568,34 @@ def _close_to_num(o1, o2, epsilon=5):
delta = abs((o2-o1)*MUSECONDS_PER_DAY)
assert(delta<epsilon)
+def epoch2num(e):
+ """
+ convert an epoch or sequence of epochs to the new date format,
+ days since 0001
+ """
+ spd = 24.*3600.
+ return 719163 + asarray(e)/spd
+
+def num2epoch(d):
+ """
+ convert days since 0001 to epoch. d can be a number or sequence
+ """
+ spd = 24.*3600.
+ return (asarray(d)-719163)*spd
+
+def mx2num(m):
+ """
+ Convert mx datetime instance (or sequence of mx instances) to the
+ new date format,
+ """
+ scalar = False
+ if not iterable(m):
+ scalar = True
+ m = [m]
+ ret = epoch2num([m.ticks() for m in mxdates])
+ if scalar: return ret[0]
+ else: return ret
+
if __name__=='__main__':
#tz = None
@@ -621,3 +649,4 @@ def _close_to_num(o1, o2, epsilon=5):
for t in dates: print formatter(t)
+
View
36 lib/matplotlib/matlab.py
@@ -319,6 +319,40 @@ def %s(*args, **kwargs):
%s.__doc__ = Axes.%s.__doc__
"""
+def changed_name_function(f, newname):
+ import new
+ if matplotlib._python23:
+ newf = new.function(f.func_code, f.func_globals, newname,
+ f.func_defaults, f.func_closure)
+ else:
+ #if f.func_defaults is None:
+ # argdefs = ()
+ #else:
+ argdefs = f.func_defaults
+ newf = new.function(f.func_code, f.func_globals, newname,
+ argdefs)
+
+ print f.func_defaults
+ newf.__doc__ = f.__doc__
+ return newf
+
+def _wrap_axfunc(name):
+ def wrapper(*args, **kwargs):
+ try:
+ func = getattr(gca(), name)
+ ret = func(*args, **kwargs)
+ except ValueError, msg:
+ msg = raise_msg_to_str(msg)
+ error_msg(msg)
+ else:
+ draw_if_interactive()
+ return ret
+ wrapper.__doc__ = getattr(Axes, name).__doc__
+ #wrapper.__name__ = name
+ return changed_name_function(wrapper, name)
+
+
+
# these methods are all simple wrappers of Axes methods by the same
# name. We'll autogenerate these to avoid some of the boilerplate
# using the fmt string above.
@@ -355,8 +389,10 @@ def %s(*args, **kwargs):
)
for name in _methods:
+ #locals[name] = _wrap_axfunc(name)
exec(__fmt%(name, name, name, name))
+#plot = _wrap_axfunc('plot')
def axis(*v):
"""\
View
26 license.py
@@ -5,22 +5,7 @@
version = sys.argv[1]
-if sys.argv[2] == 'htdocs/license.html.template':
- s = """\
-@header@
-
-<h2>License</h2>
-
-The matplotlib license is a shameless ripoff of the python license.<p>
-
-<pre>
-
-"""
-else:
- s = ""
-
-
-s += """\
+s = """\
LICENSE AGREEMENT FOR MATPLOTLIB %(version)s
--------------------------------------
@@ -72,15 +57,6 @@
Agreement.
""" % locals()
-if sys.argv[2] == 'htdocs/license.html.template':
- s += """\
-
-</pre>
-
-@footer@
-"""
-else:
- pass
file(sys.argv[2], 'w').write(s)

0 comments on commit 3a301cd

Please sign in to comment.
Something went wrong with that request. Please try again.