jaggies

14 views
Skip to first unread message

zubin

unread,
Feb 7, 2009, 11:09:29 PM2/7/09
to ggp...@googlegroups.com
quick, question - for ggplot2 graphics, titles and text labels -
resizing them create jaggies, like they are not vector fonts or such.
how does one use a font or such that scales like a vector image?

-zubin

hadley wickham

unread,
Feb 7, 2009, 11:20:21 PM2/7/09
to zubin, ggp...@googlegroups.com
Hi Zubin,

If you're saving them to a vector format (i.e. emf, pdf, eps) they'll
be vector, otherwise they'll be raster. If you're seeing jaggies in
some other situation, could you please provide more information?

Hadley
--
http://had.co.nz/

zubin

unread,
Feb 7, 2009, 11:27:29 PM2/7/09
to hadley wickham, ggp...@googlegroups.com, harsh....@mu-sigma.com
Yes, we are saving them to a .png file and inserting into a pdf via  pdflatex and sweave.  I attached a sample plot.

Upon zoom, using adobe pdf, everything zooms perfect except for the axis and title labels.  wanted to try EPS however my developer indicates eps is not supported by pdflatex, but we are researching.  thx for the response. 

-zubin



hadley wickham wrote:
quick, question - for ggplot2 graphics, titles and text labels -
resizing them create jaggies, like they are not vector fonts or such.
how does one use a font or such that scales like a vector image?

-zubin

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the ggplot2 mailing list.
To post to this group, send email to ggp...@googlegroups.com
To unsubscribe from this group, send email to
ggplot2+u...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/ggplot2
-~----------~----~----~----~------~----~------~--~---


    


  

Wayne Folta

unread,
Feb 7, 2009, 11:35:22 PM2/7/09
to ggplot2, zubin
Zubin,

You save to a PNG, which is not vector-based. Taking a non-vector graph into a vector-capable format file, like PDF, won't change that. You'll want to output to PDF in the first place, or use Cairo for outputting to PNG, which should make things much smoother.


On Feb 7, 2009, at 11:27 PM, zubin wrote:

Yes, we are saving them to a .png file and inserting into a pdf via  pdflatex and sweave.  I attached a sample plot.

Upon zoom, using adobe pdf, everything zooms perfect except for the axis and title labels.  wanted to try EPS however my developer indicates eps is not supported by pdflatex, but we are researching.  thx for the response. 

-zubin

<moz-screenshot-1.jpg>

baptiste auguie

unread,
Feb 8, 2009, 6:07:30 AM2/8/09
to hadley wickham, ggp...@googlegroups.com
Dear all,

A related question has been itching me for a while, I'd be curious to hear opinions about this (copied from a post to R-help that received no answer).

My favorite output format is usually pdf. I can include the graphics in pdflatex documents and benefit from the scalable nature of vector graphic formats.
However, I recently had to generate high-res 2D levelplot graphics as in the example below,

N <- 100
# N <- 1000 # slow to render, made my MacBook Pro unusable for minutes
xy <- expand.grid(x=seq(0, 10, length=N), y=seq(0, 10, length=N))

xy <- within(xy, z <- x^2*cos(x*y))

library(ggplot2)

p <- qplot(x, y, data = xy, geom = "tile", fill = z)

pdf("plot.pdf")
print(p)
dev.off()

png("plot.png")
print(p)
dev.off()


With N=1000, this approach produces a hefty pdf file of ~39MB (similar lattice output was 29MB for some reason), while the png file with default resolution is only 164kB. It is clear that I don't want to include the pdf figure in a manuscript, as most pdf readers (let alone the printer) will painfully stall when scrolling down the document. The png file has a good enough resolution (this could be tuned anyway) as far as the levelplot is concerned, however the text and labels are evidently converted to bitmap. I would like to ask whether there are some alternative ways to combine the "best of both worlds" in ggplot or R in general, that is to create a pdf file with part of the output being an embedded bitmap (the levelplot in this case). Xfig, as I recall, has a way to produce two separate files for this kind of purpose: one containing the graphical information stripped of annotations, the other the labels and axes to be processed by TeX. Because of the layer and object approach in grid graphics, it seems that it ought to be possible to create two such temporary files with exactly the same dimensions and combine them into a light-weight, mixed type pdf. Such a feature, even experimental, would be very neat and useful.

On a side note, I noticed that Acrobat Professional can substantially reduce the file size, but it does not seem to help some pdf readers (Preview on Leopard, for one). I'm open to suggestions of auxiliary tools that might help.


Best regards,

baptiste



From: hadley wickham <h.wi...@gmail.com>
To: zubin <zu...@dowlaty.com>
Cc: ggp...@googlegroups.com
Sent: Sunday, 8 February, 2009 4:20:21
Subject: Re: jaggies

hadley wickham

unread,
Feb 8, 2009, 9:22:04 AM2/8/09
to baptiste auguie, ggp...@googlegroups.com
> With N=1000, this approach produces a hefty pdf file of ~39MB (similar
> lattice output was 29MB for some reason), while the png file with default
> resolution is only 164kB. It is clear that I don't want to include the pdf
> figure in a manuscript, as most pdf readers (let alone the printer) will
> painfully stall when scrolling down the document. The png file has a good
> enough resolution (this could be tuned anyway) as far as the levelplot is
> concerned, however the text and labels are evidently converted to bitmap. I
> would like to ask whether there are some alternative ways to combine the
> "best of both worlds" in ggplot or R in general, that is to create a pdf
> file with part of the output being an embedded bitmap (the levelplot in this
> case). Xfig, as I recall, has a way to produce two separate files for this
> kind of purpose: one containing the graphical information stripped of
> annotations, the other the labels and axes to be processed by TeX. Because
> of the layer and object approach in grid graphics, it seems that it ought to
> be possible to create two such temporary files with exactly the same
> dimensions and combine them into a light-weight, mixed type pdf. Such a
> feature, even experimental, would be very neat and useful.

Something like this would be great, and I'd definitely take advantage
of it if it was available. However, I suspect it would require fairly
deep changes to the pdf device and there are probably few people with
the time, knowledge and motivation to make the changes.

For the book, I'm using 600 dpi pngs for the images where pdf's are
too heavy. You shouldn't be able to see any difference when printed.
(And in fact I may end up turning all of the images into pdfs as the
production process as Springer seems to be running into problems with
pdfs)

Hadley

--
http://had.co.nz/

Reply all
Reply to author
Forward
0 new messages