|
From: Michael H. <mh...@us...> - 2009-10-14 21:04:22
Attachments:
testfig.pdf
|
I have attached a PDF created with matplotib/basemap. On my mac, Preview opens this file without any errors. However, Adobe Acrobat 9.2.0 (Mac) reports this error: "An error exists on this page. Acrobat may not display the page correctly. Please contact the person who created the PDF document to correct the problem." It then goes ahead and displays the image correctly. I have found similar issues with Illustrator, and older versions of Acrobat Professional where those pieces of software are unable to open the PDF at all. The only free software I could find to validate PDFs (http://multivalent.sourceforge.net/index.html ) has no complaints about this file. Does anyone have any idea what might be causing these errors to (sometimes) occur? Info: matplotlib: 0.99.0 basemap: 0.99.4 The code that created the PDF is below: #!/usr/bin/env python import matplotlib matplotlib.use('agg') from mpl_toolkits.basemap import Basemap from pylab import savefig,close,figure,arange,array figwidth=6 figheight=6 clat = 39.132332 clon = -98.261719 fig = figure(figsize=(figwidth,figheight),edgecolor='g',facecolor='g') ax1 = fig.add_axes([0,0,1.0,1.0]) map = Basemap(resolution='c', projection='ortho', lon_0=clon,lat_0=clat,ax=ax1) map.drawcountries(linewidth=0.1,color=[0.2,0.2,0.2]) map.drawcoastlines(linewidth=0.05,color=[0.2,0.2,0.2]) map.drawlsmask((230,230,230,255),(119,155,207,255)) meridians = arange(-180,210,30) parallels = arange(-90,120,30) map .drawmeridians(meridians,linewidth=0.1,dashes=[1,0],color=[0.2,0.2,0.2]) map .drawparallels(parallels,linewidth=0.1,dashes=[1,0],color=[0.2,0.2,0.2]) pcx,pcy = map(clon,clat) map .plot (array ([pcx]),array([pcy]),'ro',linewidth=1,markersize=5,markeredgecolor='r') map.drawmapboundary(color='k',linewidth=2.0) savefig('testfig.pdf') close('all') |
|
From: Jouni K. S. <jk...@ik...> - 2009-10-15 06:42:46
|
Michael Hearne <mh...@us...> writes: > I have attached a PDF created with matplotib/basemap. On my mac, > Preview opens this file without any errors. However, Adobe Acrobat > 9.2.0 (Mac) reports this error: > > "An error exists on this page. Acrobat may not display the page > correctly. Please contact the person who created the PDF document to > correct the problem." This is probably a bug in the pdf backend. Ghostscript 8.62 complains with "Error: /nocurrentpoint in --run--". This suggests that an "m" (moveto) command is missing somewhere. I'm too busy to debug this today, but please file a bug in the tracker. -- Jouni K. Seppänen http://www.iki.fi/jks |
|
From: Jouni K. S. <jk...@ik...> - 2009-10-21 19:10:54
|
Could somebody test that script with current trunk (rev. 7899)? I don't have basemap installed, but I think my latest change might shake out the bug. -- Jouni K. Seppänen http://www.iki.fi/jks |
|
From: Jeff W. <js...@fa...> - 2009-10-21 20:54:21
|
Jouni K. Seppänen wrote:
> Could somebody test that script with current trunk (rev. 7899)? I don't
> have basemap installed, but I think my latest change might shake out the
> bug.
>
>
Jouni: That test script now crashes with:
Traceback (most recent call last):
File "testpdf.py", line 28, in <module>
savefig('testfig.pdf')
File "/Users/jwhitaker/lib/python/matplotlib/pyplot.py", line 355, in
savefig
return fig.savefig(*args, **kwargs)
File "/Users/jwhitaker/lib/python/matplotlib/figure.py", line 1055, in
savefig
self.canvas.print_figure(*args, **kwargs)
File "/Users/jwhitaker/lib/python/matplotlib/backend_bases.py", line
1618, in print_figure
**kwargs)
File "/Users/jwhitaker/lib/python/matplotlib/backend_bases.py", line
1476, in print_pdf
return pdf.print_pdf(*args, **kwargs)
File "/Users/jwhitaker/lib/python/matplotlib/backends/backend_pdf.py",
line 2094, in print_pdf
self.figure.draw(renderer)
File "/Users/jwhitaker/lib/python/matplotlib/artist.py", line 55, in
draw_wrapper
draw(artist, renderer, *kl)
File "/Users/jwhitaker/lib/python/matplotlib/figure.py", line 772, in draw
for a in self.axes: a.draw(renderer)
File "/Users/jwhitaker/lib/python/matplotlib/artist.py", line 55, in
draw_wrapper
draw(artist, renderer, *kl)
File "/Users/jwhitaker/lib/python/matplotlib/axes.py", line 1761, in draw
a.draw(renderer)
File "/Users/jwhitaker/lib/python/matplotlib/artist.py", line 55, in
draw_wrapper
draw(artist, renderer, *kl)
File "/Users/jwhitaker/lib/python/matplotlib/lines.py", line 533, in draw
drawFunc(renderer, gc, tpath, affine.frozen())
File "/Users/jwhitaker/lib/python/matplotlib/lines.py", line 869, in
_draw_lines
self._lineFunc(renderer, gc, path, trans)
File "/Users/jwhitaker/lib/python/matplotlib/lines.py", line 920, in
_draw_dashed
renderer.draw_path(gc, path, trans)
File "/Users/jwhitaker/lib/python/matplotlib/backends/backend_pdf.py",
line 1353, in draw_path
rgbFace is None and gc.get_hatch_path() is None)
File "/Users/jwhitaker/lib/python/matplotlib/backends/backend_pdf.py",
line 1235, in writePath
cmds = self.pathOperations(path, transform, clip)
File "/Users/jwhitaker/lib/python/matplotlib/backends/backend_pdf.py",
line 1214, in pathOperations
raise ValueError, 'Path lacks initial MOVETO'
ValueError: Path lacks initial MOVETO
--
Jeffrey S. Whitaker Phone : (303)497-6313
Meteorologist FAX : (303)497-6449
NOAA/OAR/PSD R/PSD1 Email : Jef...@no...
325 Broadway Office : Skaggs Research Cntr 1D-113
Boulder, CO, USA 80303-3328 Web : http://tinyurl.com/5telg
|
|
Re: [matplotlib-devel] Should Path objects have an initial MOVETO?
(was: error with basemap and pdf)
From: Michael D. <md...@st...> - 2009-10-22 12:35:21
|
Jouni K. Seppänen wrote: > Jeff Whitaker <js...@fa...> writes: > > >> Jouni: That test script now crashes with: >> >> File "/Users/jwhitaker/lib/python/matplotlib/backends/backend_pdf.py", >> line 1214, in pathOperations >> raise ValueError, 'Path lacks initial MOVETO' >> ValueError: Path lacks initial MOVETO >> > > I think this confirms my suspicion that the bug is really elsewhere. A > path in PDF needs to begin with a "m" that sets the initial point, and > that particular Path object only consisted of one LINETO operation. Am I > correct in thinking that this is an invalid path? > Yes -- that path should be considered invalid, though the Path class doesn't do any verification. I'll add this. I'm surprised that it's coming from the line class, which in general doesn't allow for customization of the path codes. There must be something unanticipated happening. Cheers, Mike -- Michael Droettboom Science Software Branch Operations and Engineering Division Space Telescope Science Institute Operated by AURA for NASA |
|
From: Michael D. <md...@st...> - 2009-10-22 13:47:08
|
The bug was actually in the path simplification. In really degenerate cases (bravo for finding it) of paths that are completely outside of the clip region, it would create a path with a single LINETO command. This is now fixed in SVN on the branch and trunk. Mike Michael Droettboom wrote: > Jouni K. Seppänen wrote: > >> Jeff Whitaker <js...@fa...> writes: >> >> >> >>> Jouni: That test script now crashes with: >>> >>> File "/Users/jwhitaker/lib/python/matplotlib/backends/backend_pdf.py", >>> line 1214, in pathOperations >>> raise ValueError, 'Path lacks initial MOVETO' >>> ValueError: Path lacks initial MOVETO >>> >>> >> I think this confirms my suspicion that the bug is really elsewhere. A >> path in PDF needs to begin with a "m" that sets the initial point, and >> that particular Path object only consisted of one LINETO operation. Am I >> correct in thinking that this is an invalid path? >> >> > Yes -- that path should be considered invalid, though the Path class > doesn't do any verification. I'll add this. I'm surprised that it's > coming from the line class, which in general doesn't allow for > customization of the path codes. There must be something unanticipated > happening. > > Cheers, > Mike > > -- Michael Droettboom Science Software Branch Operations and Engineering Division Space Telescope Science Institute Operated by AURA for NASA |
|
From: Jouni K. S. <jk...@ik...> - 2009-10-22 04:21:33
|
Jeff Whitaker <js...@fa...> writes: > Jouni: That test script now crashes with: > > File "/Users/jwhitaker/lib/python/matplotlib/backends/backend_pdf.py", > line 1214, in pathOperations > raise ValueError, 'Path lacks initial MOVETO' > ValueError: Path lacks initial MOVETO I think this confirms my suspicion that the bug is really elsewhere. A path in PDF needs to begin with a "m" that sets the initial point, and that particular Path object only consisted of one LINETO operation. Am I correct in thinking that this is an invalid path? I'm not too familiar with Path (and I'm terribly busy today) but I think the way to catch this bug is to add a sanity check to Path, similar to the check in the pdf backend that produces that error. Then the traceback would show what code is creating the invalid path -- the traceback from the backend is too late in the execution to tell us that. -- Jouni K. Seppänen http://www.iki.fi/jks |