line not saved with ggsave and pdf, but well displayed on screen

214 views
Skip to first unread message

Matthieu Dubois

unread,
Jul 2, 2009, 3:48:27 AM7/2/09
to Ggplot2 Help
Dear all, 

I'm sorry to come with one more problem. I'm not sure this is the adequate list to post it, as the it may also be related to R-mac. 

I generated a basic plot (code below), in which a dotted curve is displayed. When saving the plot with ggsave and pdf(), the curve is not visible in the resulting file. On the contrary, when saving in pdf from the graphical window (using save as ...), there was no problem at all. Do you know why ? 


I added the generated files in attachement: Quartz.pdf is the saved figure from on-sreen printing; pdf.pdf is the figure saved by means of pdf() ... dev.off() and ggsave.pdf by means of ggsave(). The line do not show in the last two using two different pdf readers (Preview.app and Skim.app) . Particularly small dots are visible when using Adobe Acrobat Pro 9. On the contrary, everything is normal in Quartz.pdf.

I'm using R version 2.9.1 (2009-06-26) on an 2.4 GHz intel Core 2 duo Mac running Mac OS 10.5.7. 

# generate data
data <- data.frame(x=rnorm(1000))

# basic hist with density and normal curve
p <- ggplot(data, aes(x)) +  
geom_histogram(aes(y=..density..), col='black', fill="grey") + 
geom_density() + 
stat_function(fun=dnorm, args=list(mean=mean(data$x), sd=sd(data$x)), linetype=3)

# the dashed normal curve is well rendered
# quartz()
p

# the dashed normal curve is not saved with ggsave and pdf
pdf("pdf.pdf")
p
dev.off()
ggsave("ggsave.pdf",p)

Best, 

Matthieu

Quartz.pdf
pdf.pdf
ggsave.pdf

hadley wickham

unread,
Jul 2, 2009, 10:27:17 AM7/2/09
to Matthieu Dubois, Ggplot2 Help
Hi Mattheiu,

Neither pdf.pdf nor ggsave.pdf opened for me. But I think this might
be similar to a problem that cropped up on the list couple of weeks
ago - can you try printing the pdfs and see if they look the same?

Hadley

> Matthieu Dubois
> Post-doctoral fellow
> Psychology and NeuroCognition Lab (CNRS UMR 5105)
> Université Pierre Mendès-France
> BP47 --- 38040 Grenoble Cedex 9 --- France
> Email: matthie...@upmf-grenoble.fr
> Gmail: matt...@gmail.com
> http://web.upmf-grenoble.fr/LPNC/membre_matthieu_dubois
>
>
>
>
>

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

Matthieu Dubois

unread,
Jul 2, 2009, 10:44:44 AM7/2/09
to hadley wickham, Ggplot2 Help
Hi,

the dotted line does not print for the plots generated with ggplot and
pdf or ggsave. On the contrary, there is no problem when using the
same line type in base graphics and pdf().

Matthieu


Le 2 juil. 09 à 16:27, hadley wickham a écrit :

Reply all
Reply to author
Forward
0 new messages