EPS to PDF contour plots [message #75568] |
Fri, 01 April 2011 12:49  |
Matt[3]
Messages: 23 Registered: April 2011
|
Junior Member |
|
|
Hi All,
I see that something like this has been posted several times before,
but I can't seem to find a simple solution...
I'm generating eps contour plots using David Fanning's great new
routines and the /cell_fill option. However, some of them have the
well-known 'stripe' effect that is discussed in David's book. My
question is this: How can I convert these eps files to pdf format
without the stripes, and without the pdfs files being too large? If I
use ImageMagick with +antialias, I can only get the fonts to look nice
if I really crank up the density, which leads to huge pdfs. I'm
assuming that this is because they are first converted to raster
images and then to pdf. Is there a way to keep this all in vector
format? The file size is a problem, because it makes the document
they are going into huge, and very slow to navigate (and the plots
don't seem to look great in some viewers).
At the moment I'm just doing the conversion using epstopdf.
I know that this isn't really an IDL question, but if anyone has found
a solution, it'd be very much appreciated.
Cheers,
Matt
|
|
|
Re: EPS to PDF contour plots [message #75681 is a reply to message #75568] |
Tue, 05 April 2011 09:07   |
Heinz Stege
Messages: 189 Registered: January 2003
|
Senior Member |
|
|
On Tue, 5 Apr 2011 09:18:00 -0600, David Fanning wrote:
> Of course, there is always the possibility that
> the software we are using to *view* the PostScript
> and PDF files are screwing it up. We are not, after
> all, looking at the original data, but the representation
> of the data as presented on the display. The proof,
> I suppose, is what happens when we print the file,
> since this is the purpose of PostScript output.
>
That is a good point. When I open the PDF (created by Ghostscript)
with the IrfanView image viewer (version 4.27), I do see horizontal
and vertical stripes. And, as told already last night, when I open the
same PDF with the Adobe Reader (version 7.1.4 [I know it's not the
latest version]), there are no stripes.
May be, that it has to do with the way, how the vector graphic is
convertet to a bitmap.
Cheers, Heinz
|
|
|
|
Re: EPS to PDF contour plots [message #75683 is a reply to message #75568] |
Tue, 05 April 2011 08:18   |
David Fanning
Messages: 11724 Registered: August 2001
|
Senior Member |
|
|
Matt writes:
> Thanks Heinz. That's really strange, because when I issue the same
> command on my mac, I'm still getting the stripes (same file size
> though). The appearance is slightly different if I view the pdf in
> Preview, Safari or in Acrobat. But they all have stripes.
>
> I just tried the same thing on Linux, and then went and used Distiller
> on a Windows machine. Same deal. How can different people be getting
> different results with the same file? Maybe my eyes are the problem?!
The only thing that can possibly make sense here
is that this is a version problem in the software
we are using to convert the PostScript file to a PDF
file.
I am using Adobe Acrobat Pro, version 9 to do the
conversion. I've tried the conversion with several
different combinations of settings and I always
get a clear PDF file.
Of course, there is always the possibility that
the software we are using to *view* the PostScript
and PDF files are screwing it up. We are not, after
all, looking at the original data, but the representation
of the data as presented on the display. The proof,
I suppose, is what happens when we print the file,
since this is the purpose of PostScript output.
Cheers,
David
--
David Fanning, Ph.D.
Fanning Software Consulting, Inc.
Coyote's Guide to IDL Programming: http://www.idlcoyote.com/
Sepore ma de ni thui. ("Perhaps thou speakest truth.")
|
|
|
|
Re: EPS to PDF contour plots [message #75685 is a reply to message #75568] |
Tue, 05 April 2011 07:59   |
Matt[3]
Messages: 23 Registered: April 2011
|
Junior Member |
|
|
On Apr 4, 8:04 pm, Heinz Stege <public.215....@arcor.de> wrote:
Here is, what I did on Windows:
>
> input_file='test.ps'
> output_file='test.pdf'
> command='"C:\Program Files\gs\gs8.61\bin\gswin32c.exe" '+$
> '-q -dBATCH -dNOPAUSE -sDEVICE=pdfwrite -dPDFSETTINGS=/prepress '+$
> '-dAutoRotatePages=/PageByPage -sOutputFile="'+output_file+'" '+$
> input_file
> spawn,command,stdout,stderr,/noshell
> print,stdout,stderr
>
> For me the PDF looks perfect. No stripes.
>
> The filesize of the test.pdf is 60 kB.
>
> HTH, Heinz
Thanks Heinz. That's really strange, because when I issue the same
command on my mac, I'm still getting the stripes (same file size
though). The appearance is slightly different if I view the pdf in
Preview, Safari or in Acrobat. But they all have stripes.
I just tried the same thing on Linux, and then went and used Distiller
on a Windows machine. Same deal. How can different people be getting
different results with the same file? Maybe my eyes are the problem?!
Cheers,
Matt
|
|
|
Re: EPS to PDF contour plots [message #75692 is a reply to message #75568] |
Mon, 04 April 2011 17:43   |
David Fanning
Messages: 11724 Registered: August 2001
|
Senior Member |
|
|
Heinz Stege writes:
> there are no stripes within the graphics, when you use Ghostscript to
> convert the Postscript file to PDF. You can even do it from the IDL
> command line. Here is, what I did on Windows:
>
> input_file='test.ps'
> output_file='test.pdf'
> command='"C:\Program Files\gs\gs8.61\bin\gswin32c.exe" '+$
> '-q -dBATCH -dNOPAUSE -sDEVICE=pdfwrite -dPDFSETTINGS=/prepress '+$
> '-dAutoRotatePages=/PageByPage -sOutputFile="'+output_file+'" '+$
> input_file
> spawn,command,stdout,stderr,/noshell
> print,stdout,stderr
>
> For me the PDF looks perfect. No stripes.
No, I don't see any stripes either using this
method or using Adobe Distiller. I don't quite
know what to make of it all. :-)
Cheers,
David
--
David Fanning, Ph.D.
Fanning Software Consulting, Inc.
Coyote's Guide to IDL Programming: http://www.idlcoyote.com/
Sepore ma de ni thui. ("Perhaps thou speakest truth.")
|
|
|
Re: EPS to PDF contour plots [message #75694 is a reply to message #75568] |
Mon, 04 April 2011 17:04   |
Heinz Stege
Messages: 189 Registered: January 2003
|
Senior Member |
|
|
On Mon, 4 Apr 2011 08:58:09 -0700 (PDT), Matt wrote:
> On Apr 4, 11:38�am, David Fanning <n...@idlcoyote.com> wrote:
>
>> Is there any chance you can make the PostScript file available?
>>
>> Cheers,
>>
>> David
>>
>
> Sure. It's here: http://dl.dropbox.com/u/13779929/Test.ps. I've been
> playing around with it a bit, so it's a slightly different version to
> the PDF above, but same idea.
>
> Cheers,
>
> Matt
Hi Matt,
there are no stripes within the graphics, when you use Ghostscript to
convert the Postscript file to PDF. You can even do it from the IDL
command line. Here is, what I did on Windows:
input_file='test.ps'
output_file='test.pdf'
command='"C:\Program Files\gs\gs8.61\bin\gswin32c.exe" '+$
'-q -dBATCH -dNOPAUSE -sDEVICE=pdfwrite -dPDFSETTINGS=/prepress '+$
'-dAutoRotatePages=/PageByPage -sOutputFile="'+output_file+'" '+$
input_file
spawn,command,stdout,stderr,/noshell
print,stdout,stderr
For me the PDF looks perfect. No stripes.
The filesize of the test.pdf is 60 kB.
HTH, Heinz
|
|
|
Re: EPS to PDF contour plots [message #75696 is a reply to message #75568] |
Mon, 04 April 2011 14:56   |
Matt[3]
Messages: 23 Registered: April 2011
|
Junior Member |
|
|
On Apr 4, 4:26 pm, David Fanning <n...@idlcoyote.com> wrote:
> I typically use images instead of filled contours, too, in these
> situations, but I am very curious now to see the commands you
> used to create this PostScript file. I think it is a combination
> of a filled contour on a map projection that is causing the
> problem.
>
> I am curious to see if my solution to the gridding problem I
> am working on is also a solution to Matt's problem.
These are the relevant lines from my map plotting routine. The plot
above uses the version with the 'levels' set, but the scratches appear
whether the levels are specified or not:
ps_start, filename=filename
!p.multi=[0, 2, 1]
MAP_SET, limit=limit, position=[0.02, 0.05, 0.8, 0.95], $
title=title, charsize=charsize, /noborder, /isotropic
ctload, ct, brewer=brewer, reverse=reverse_ct
if keyword_set(levels) then $
fsc_contour, data, lon, lat, /overplot, /cell_fill, levels=levels,
missingvalue=missingvalue $
else $
fsc_contour, data, lon, lat, /overplot, /cell_fill,
nlevels=nlevels
ctload, 0
map_continents, thick=3
ctload, ct, brewer=brewer, reverse=reverse_ct
if keyword_set(levels) then $
fsc_colorbar, position=[0.93, 0.05, 0.98, 0.95], $
minrange=min(levels), maxrange=max(levels), /vertical,
$ ;ticknames=string(levels, format='(e8.1)')
title=cbtitle, divisions=n_elements(levels)-1, ticknames=labels
$
else $
fsc_colorbar, position=[0.93, 0.05, 0.98, 0.95], $
minrange=min(data, /nan), maxrange=max(data, /nan), /vertical, $
title=cbtitle
fsc_text, 0.05, 0.9, plot_label, /normal, charsize=1.5
ps_end
Cheers,
Matt
|
|
|
Re: EPS to PDF contour plots [message #75697 is a reply to message #75568] |
Mon, 04 April 2011 13:26   |
David Fanning
Messages: 11724 Registered: August 2001
|
Senior Member |
|
|
Matt writes:
> Maybe I misunderstood David's previous post... You want to see what
> comes up in a plotting window? I'd never actually done that before
> for this plot, since I almost always plot straight to PS. Anyway,
> here's a screen-shot of what comes up just with ps_start commented
> out: http://dl.dropbox.com/u/13779929/IDL_screen_shot.png. Clearly
> some issues with the background color that I need to think about, but
> otherwise it's stripe-less. Also, if I use /fill, rather than /
> cell_fill, the plots look fine where there aren't missing values. I'm
> certain it's not something in the data.
Well now, this is MOST interesting!
I happen to be writing an article today about a problem
that came up doing filled contour plots on a map projection.
This is a problem with gridding, but in playing around with it
just a moment ago, I saw all these scratch-like marks in the PostScript
file I created to generate a PNG file for my web page. There were
no scratch marks in the PNG file. This is the first time I have
*ever* seen scratch marks in the PostScript file!
On closer inspection, these marks are *exactly* the outlines of
the triangles I was using to grid the data! Now, here is the interesting
thing. Matt's mention of the problem disappearing with the use of
the FILL keyword instead of the CELL_FILL keyword caused me to
try the (totally INCORRECT!!!) FILL keyword on this map projection.
He is right, the scratches (triangle outlines) completely disappear!
Of course, now the colors are completely wrong, but, heck, we seem
to be making progress here. :-)
So, there is something about CELL_FILL on a map projection that is
causing a problem. It really looks like a rounding problem to me,
where the triangles are just not always coming completely and seamlessly
together.
> I've just given Ken's routines a try and it looks like they might
> solve the problem! I'll need to play around with it a bit to get a
> better feel for it.
>
> It does seem like a shame not to use contour for this. As Ken says,
> it's much simpler!
I typically use images instead of filled contours, too, in these
situations, but I am very curious now to see the commands you
used to create this PostScript file. I think it is a combination
of a filled contour on a map projection that is causing the
problem.
I am curious to see if my solution to the gridding problem I
am working on is also a solution to Matt's problem.
Cheers,
David
--
David Fanning, Ph.D.
Fanning Software Consulting, Inc.
Coyote's Guide to IDL Programming: http://www.idlcoyote.com/
Sepore ma de ni thui. ("Perhaps thou speakest truth.")
|
|
|
Re: EPS to PDF contour plots [message #75698 is a reply to message #75568] |
Mon, 04 April 2011 13:01   |
Matt[3]
Messages: 23 Registered: April 2011
|
Junior Member |
|
|
On Apr 4, 2:59 pm, David Fanning <n...@idlcoyote.com> wrote:
> Kenneth P. Bowman writes:
>> These are rendering artifacts from converting the PS/PDF to a
>> bitmap to display it on the screen. They are a result of the
>> PS being comprised of a number of individual polygons.
>> If you zoom into the PDF, you will see that the artifacts are
>> resolution dependent.
>
> I agree they look *exactly* like rendering artifacts,
> but I see no evidence the artifacts are resolution dependent.
> No matter what resolution I use on that PDF file, the artifacts
> are still there. :-(
>
Hi Guys,
Maybe I misunderstood David's previous post... You want to see what
comes up in a plotting window? I'd never actually done that before
for this plot, since I almost always plot straight to PS. Anyway,
here's a screen-shot of what comes up just with ps_start commented
out: http://dl.dropbox.com/u/13779929/IDL_screen_shot.png. Clearly
some issues with the background color that I need to think about, but
otherwise it's stripe-less. Also, if I use /fill, rather than /
cell_fill, the plots look fine where there aren't missing values. I'm
certain it's not something in the data.
I've just given Ken's routines a try and it looks like they might
solve the problem! I'll need to play around with it a bit to get a
better feel for it.
It does seem like a shame not to use contour for this. As Ken says,
it's much simpler!
Cheers,
Matt
|
|
|
|
Re: EPS to PDF contour plots [message #75700 is a reply to message #75568] |
Mon, 04 April 2011 11:13   |
Kenneth P. Bowman
Messages: 585 Registered: May 2000
|
Senior Member |
|
|
In article
<812f3ec8-351f-4b8c-8f9f-454634a9c28e@hd10g2000vbb.googlegroups.com>,
Matt <theothermattrigby@gmail.com> wrote:
> http://dl.dropbox.com/u/13779929/ps_converted_distiller.pdf
These are rendering artifacts from converting the PS/PDF to a
bitmap to display it on the screen. They are a result of the
PS being comprised of a number of individual polygons.
If you zoom into the PDF, you will see that the artifacts are
resolution dependent. That said, I think it is a bug that the
renderer produces these artifacts.
For me the easiest way workaround is to use an image for
the color, rather than using CONTOUR. This approach is
more complicated than using CONTOUR, because you
have to do it differently depending on the device.
Here is a code snippet showing how to handle PS/PDF and X devices.
MAP_IMAGE_KPB is my wrapper for MAP_IMAGE that handles missing data (NANs).
You should be able to use MAP_IMAGE. COLOR_LOOKUP_24_KPB is my function
to scale physical data into colors. IMAGE_24_KPB converts color values
stored as LONGs into RGB bytes.
You can download my routines from here
http://csrp.tamu.edu/downloads/idl/bowman_lib.zip
Using images instead of CONTOUR has some advantages. The resulting
PS files are often much smaller and display more quickly.
Ken Bowman
pixel_scale = 0.05 ;You might need to adjust this to get the right image resolution
MAP_SET, /CYLINDRICAL, /ISOTROPIC, /NOBORDER, LIMIT = [ymin, xmin, ymax, xmax] ;Map projection
data_map = MAP_IMAGE_KPB(REFORM(y[*,*,k]), i0, j0, ni, nj, /BILINEAR, COMPRESS = 1, $ ;Project data to map
SCALE = pixel_scale, LONMIN = xmin, LONMAX = xmax, LATMIN = ymin, LATMAX = ymax)
data_image = COLOR_LOOKUP_24_KPB(data_map, rdf_colors, MIN = y0min, MAX = y0max, $ ;Convert to color image
UNDER_COLOR = rdf_colors[0], OVER_COLOR = rdf_colors[-1])
IF (KEYWORD_SET(eps) OR KEYWORD_SET(pdf)) THEN BEGIN
TV, IMAGE_24_KPB(data_image, TRUE = 3), i0, j0, TRUE = 3, XSIZE = ni, YSIZE = nj ;Display image (PS)
ENDIF ELSE BEGIN
TV, IMAGE_24_KPB(data_image, TRUE = 3), i0, j0, TRUE = 3
ENDELSE
MAP_CONTINENTS, /CONTINENTS, /USA, COLOR = COLOR_24('gray30'), /COUNTRIES ;Draw continents
MAP_GRID, ...
|
|
|
|
Re: EPS to PDF contour plots [message #75702 is a reply to message #75568] |
Mon, 04 April 2011 10:48   |
Matt[3]
Messages: 23 Registered: April 2011
|
Junior Member |
|
|
On Apr 4, 12:02 pm, David Fanning <n...@idlcoyote.com> wrote:
> Matt writes:
>> Sure. It's here:http://dl.dropbox.com/u/13779929/Test.ps. I've been
>> playing around with it a bit, so it's a slightly different version to
>> the PDF above, but same idea.
>
> OK, now, is this the PostScript file that came directly
> from IDL, or was this processed with some other software
> between when it was created in IDL and what I am seeing
> here?
This is what came out of IDL, apart from the deletion of a bit of text
in the header with the address of my computer on it.
I can email you the code that produced it, if you'd like.
Cheers,
Matt
|
|
|
|
|
|
|
|