MathGroup Archive 1999

[Date Index] [Thread Index] [Author Index]

Search the Archive

Re: How to fix bad EPS output from Display[.., .., "EPS"]

  • To: mathgroup at
  • Subject: [mg15633] Re: [mg15582] How to fix bad EPS output from Display[.., .., "EPS"]
  • From: Brian Boonstra <boonstb at>
  • Date: Sat, 30 Jan 1999 04:28:32 -0500 (EST)
  • References: <>
  • Sender: owner-wri-mathgroup at


	I ran into some similar troubles when trying to incorporate  
Mathematica-generates EPS figures in TeX documents.  The problem is
with the bounding   box that Mathematica creates.

	At first, I wrote some Python code to fix the trouble (included  
below, no guarantees), but later I discovered the easiest way to deal
with   the problem was to copy the figure to the clipboard, paste it in
my word   processor (which fixed the BB for some reason), and save it
from there.  You   might want to try something similarly low-tech.

Dr Brian K Boonstra
Vice President, Quantitative Research

First National Bank of Chicago
1 First National Plaza
Chicago, Illinois   60670

Tel:    (312) 732-8368
Fax:    (312) 732-5068
Email:  boonstb at

===== cut here ========

def main(args = None):
	'''Main execution loop.
	Creates a new correctMmaEPSFile as a matter of course.

	import sys

	if not args:
		args = sys.argv[1:]
	if args:
		file = args[0]
		file = '-'

	if file == '-':
		f = sys.stdin
			f = open(file, 'r')
		except IOError, msg:
			print file, ":", msg

	data = f.readlines()

	if f is not sys.stdin:

	found = 0
	foundAt = 0

	# Find the bounding box line
	for line in data[:]:
		if"BoundingBox", line) >= 0:
			found = 1
			keyline = line
		foundAt = foundAt + 1

	if found:

		newfile = []

		# we will turn printing off for the first newpath...clip newpath
		# sequence, since we want to cut that out
		foundNewPath = 0
		printingOff = 0

		# parse the bounding box line for coords
		coordinates = string.split(keyline)

		firstValue = string.atof(coordinates[1])
		secondValue = string.atof(coordinates[2])
		fifthValue = string.atof(coordinates[5])

		# print lines up to bounding box
		for line in data[:foundAt]:

		# print corrected bounding box line
		newfile.append("""%%BoundingBox: 0 0  
		newfile.append("""%%HiResBoundingBox: 0 0  
"""+str(secondValue-firstValue)+" "+coordinates[5]+"\n")

		# process remaining lines, clipping first newpath and
		# fixing translate command
		for line in data[foundAt+1:]:

			# stop printing if we found first newpath
			if ("newpath",line)>-1) and not foundNewPath:
				foundNewPath = 1
				printingOff = 1

			if not printingOff:
				# fix it if it's a translation line
'+coordinates[4]+'[\.,0-9]* translate',line)>-1:
					newfile.append('0 '+coordinates[5]+'   translate\n')
					# otherwise just print it

			# turn printing back on at end of first newpath
			if ("clip newpath",line)>-1) and foundNewPath:
				printingOff = 0

		if f is sys.stdin:
			outfile = sys.stdout
				outfile = open(file, 'w')
			except IOError, msg:
				print file, ":", msg


		if f is not sys.stdin:

  • Prev by Date: Re: harder parts of list
  • Next by Date: RE: Re: nb file from mac to windows
  • Previous by thread: How to fix bad EPS output from Display[.., .., "EPS"]
  • Next by thread: Re: How to fix bad EPS output from Display[.., .., "EPS"]