# [R] Cairo pdf canvas size

Peter Langfelder peter.langfelder at gmail.com
Thu Jan 6 04:47:06 CET 2011

```On Wed, Jan 5, 2011 at 7:35 PM, Eduardo de Oliveira Horta
<eduardo.oliveirahorta at gmail.com> 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()
>
>

Wow, you must like light colors :)

To the point, just set margins, for example

par(mar = c(2,2,0.5, 0.5))

(margins are bottom, left, top, right)

after the Cairo command.

BTW, Cairo doesn't work for me either... but I tried your example by
plotting to the screen.

Peter

Notice how the canvas' margins are relatively far from the plotting area.
>
> 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
>>
>>
>
>        [[alternative HTML version deleted]]
>
> ______________________________________________
> R-help at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help