[R] Cairo pdf canvas size

David Winsemius dwinsemius at comcast.net
Thu Jan 6 04:43:52 CET 2011


On Jan 5, 2011, at 10:35 PM, Eduardo de Oliveira Horta wrote:

> Something like this:
>
> u=seq(from=-pi, to=pi, length=1000)
> f=sin(u)
> Cairo("example.pdf", type="pdf",width=12,height=12,units="cm",dpi=300)
> par(cex.axis=.6,col.axis="grey",ann=FALSE, lwd=.25,bty="n", las=1,  
> tcl=-.2, mgp=c(3,.5,0))
> xlim=c(-pi,pi)
> ylim=round(c(min(f),max(f)))
> plot(u,f,xlim,ylim,type="l",col="firebrick3", axes=FALSE)
> axis(side=1, lwd=.25, col="darkgrey", at=seq(from=xlim[1],  
> to=xlim[2], length=5))
> axis(side=2, lwd=.25, col="darkgrey", at=seq(from=ylim[1],  
> to=ylim[2], length=5))
> abline(v=seq(from=xlim[1], to=xlim[2], length=5), lwd=. 
> 25,lty="dotted", col="grey")
> abline(h=seq(from=ylim[1], to=ylim[2], length=5), lwd=. 
> 25,lty="dotted", col="grey")
> dev.off()
>
> Notice how the canvas' margins are relatively far from the plotting  
> area.
>

'frraid I an't help ya' padna'

First I tried your code:

 > Cairo("example.pdf",  
type="pdf",width=12,height=12,units="cm",dpi=300)
Error: could not find function "Cairo"

Then I tried:

 > cairo_pdf("example.pdf",  
type="pdf",width=12,height=12,units="cm",dpi=300)
Error in cairo_pdf("example.pdf", type = "pdf", width = 12, height =  
12,  :
   unused argument(s) (type = "pdf", units = "cm", dpi = 300)

So I guess someone with your as yet unstated OS can take over now.


-- 
David.


> Thanks,
>
> Eduardo
>
> On Thu, Jan 6, 2011 at 1:00 AM, David Winsemius <dwinsemius at comcast.net 
> > wrote:
>
> On Jan 5, 2011, at 9:38 PM, Eduardo de Oliveira Horta wrote:
>
> Hello,
>
> I want to save a pdf plot using Cairo, but the canvas of the saved  
> file
> seems too large when compared to the actual plotted area.
>
> Is there a way to control the relation between the canvas size and  
> the size
> of actual plotting area?
>
>
> OS?,  ... example?
>
> ==
>
> David Winsemius, MD
> West Hartford, CT
>
>

David Winsemius, MD
West Hartford, CT



More information about the R-help mailing list