Hi I want to have a rectangular plot of size 0.5*0.3 inches. I am having surprisingly a difficult time to do it... Since I will export it, I use also pdf(). The plot works fine, but once I specify the size in pdf() I get problems... see: Say I specify my plot as following: par(pin=c(0.5, 0.3),mai=rep(0.1,4), omi=rep(0.01,4), mar=c(5,4,4,2)) plot(runif(100)) If I now add pdf() par(pin=c(0.5, 0.3),mai=rep(0.1,4), omi=rep(0.01,4), mar=c(5,4,4,2)) plot(runif(100)) dev.off() The resulting pdf has not the size specified! If I specifz this size in pdf(), I get an error... pdf("try.pdf", height=0.3, width=0.5) par(pin=c(0.5, 0.3),mai=rep(0.1,4), omi=rep(0.01,4), mar=c(5,4,4,2)) plot(runif(100)) Error in plot.new() : figure margins too large So obviously pdf() is modifying some other par() parameter I could not figure out... Any idea? Thanks!! Matthieu
Dear R List Could I ask again my question about where the size of a plot should be specified (in par or pdf?). I still did not figure out, and any help would be much appreciated!! Thanks a lot! Matthieu Le 22. 02. 11 13:53, Matthieu Stigler a ?crit :> Hi > > I want to have a rectangular plot of size 0.5*0.3 inches. I am having > surprisingly a difficult time to do it... Since I will export it, I > use also pdf(). The plot works fine, but once I specify the size in > pdf() I get problems... see: > > Say I specify my plot as following: > > par(pin=c(0.5, 0.3),mai=rep(0.1,4), omi=rep(0.01,4), mar=c(5,4,4,2)) > > plot(runif(100)) > > > If I now add > > pdf() > > par(pin=c(0.5, 0.3),mai=rep(0.1,4), omi=rep(0.01,4), mar=c(5,4,4,2)) > > plot(runif(100)) > > dev.off() > > > The resulting pdf has not the size specified! > > If I specifz this size in pdf(), I get an error... > > pdf("try.pdf", height=0.3, width=0.5) > > par(pin=c(0.5, 0.3),mai=rep(0.1,4), omi=rep(0.01,4), mar=c(5,4,4,2)) > > plot(runif(100)) > > Error in plot.new() : figure margins too large > > > So obviously pdf() is modifying some other par() parameter I could not > figure out... Any idea? > > Thanks!! > > Matthieu
It should be specified in pdf() as you did. If you try pdf("try.pdf", height=2, width=2) par(pin=c(0.5, 0.3),mai=rep(0.1,4), omi=rep(0.01,4), mar=c(5,4,4,2)) plot(runif(100)) dev.off() I think the problem will become apparent. best, Ista On Wed, Feb 23, 2011 at 12:39 PM, Matthieu Stigler <matthieu.stigler at gmail.com> wrote:> Dear R List > > Could I ask again my question about where the size of a plot should be > specified (in par or pdf?). I still did not figure out, and any help would > be much appreciated!! > > Thanks a lot! > > Matthieu > > Le 22. 02. 11 13:53, Matthieu Stigler a ?crit : >> >> Hi >> >> I want to have a rectangular plot of size 0.5*0.3 inches. I am having >> surprisingly a difficult time to do it... Since I will export it, I use also >> pdf(). The plot works fine, but once I specify the size in pdf() I get >> problems... see: >> >> Say I specify my plot as following: >> >> par(pin=c(0.5, 0.3),mai=rep(0.1,4), omi=rep(0.01,4), mar=c(5,4,4,2)) >> >> plot(runif(100)) >> >> >> If I now add >> >> pdf() >> >> par(pin=c(0.5, 0.3),mai=rep(0.1,4), omi=rep(0.01,4), mar=c(5,4,4,2)) >> >> plot(runif(100)) >> >> dev.off() >> >> >> The resulting pdf has not the size specified! >> >> If I specifz this size in pdf(), I get an error... >> >> pdf("try.pdf", height=0.3, width=0.5) >> >> par(pin=c(0.5, 0.3),mai=rep(0.1,4), omi=rep(0.01,4), mar=c(5,4,4,2)) >> >> plot(runif(100)) >> >> Error in plot.new() : figure margins too large >> >> >> So obviously pdf() is modifying some other par() parameter I could not >> figure out... Any idea? >> >> Thanks!! >> >> Matthieu > > ______________________________________________ > R-help at r-project.org mailing list > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide http://www.R-project.org/posting-guide.html > and provide commented, minimal, self-contained, reproducible code. >-- Ista Zahn Graduate student University of Rochester Department of Clinical and Social Psychology http://yourpsyche.org
Thanks Mark! But how does the resulting plot look like on your machine? For me, it is terrible... I tried then removing the mai par (to 0.01), and then got huge circles... It looks like there are many more parameters, I changed then cex, got better but still many adjustments... seems a nightmare! pdf(paper="special", file="try.pdf", height=0.3, width=0.5) par(pin=c(0.5, 0.3), mai=rep(0.05,4), omi=rep(0.01,4)) plot(runif(100), cex=0.005) dev.off() Or am I missing one important parameter that would resize the whole thing? I guess the best workaround is just to specify a rectangular plot keeping values close to the usual ones, and then resize later one, as suggested by David (but could not find the thread mentioned). Thanks a lot to all of you! Matthieu Le 23. 02. 11 16:34, mark_difford at yahoo.co.uk a ?crit :> On Feb 23, 2011; 03:32pm Matthieu Stigler wrote: > >>>> I want to have a rectangular plot of size 0.5*0.3 inches. I am having >>>> surprisingly a difficult time to do it... > <...snip...> >>>> If I specifz this size in pdf(), I get an error... >>>> >>>> pdf("try.pdf", height=0.3, width=0.5) >>>> >>>> par(pin=c(0.5, 0.3),mai=rep(0.1,4), omi=rep(0.01,4), mar=c(5,4,4,2)) >>>> >>>> plot(runif(100)) >>>> >>>> Error in plot.new() : figure margins too large > You are specifying the margins twice, using different units, namely mai (in inches) and mar (in lines). The latter is throwing the error. To get what you want, try the following: > > ## > pdf(paper="special", file="try.pdf", height=0.5, width=0.3) > par(pin=c(0.5, 0.3), mai=rep(0.1,4), omi=rep(0.01,4)) > plot(runif(100)) > dev.off() > > My PDF viewer (Adobe) tells me that the page size is 0.29 x 0.50 inch. > > Regards, Mark. >> dev.off()