[R] Output formatting in PDF

Duncan Mackay dulcalma at bigpond.com
Wed Oct 12 00:05:59 CEST 2016


Hi

There is also the basic option of using the grid package and viewports.
You can then place the plots where you want and annotate them

    pdf(file    = paste0("01", ".pdf"),
        height  = 3.5,
        width   = 7,
        paper   = "special",
        onefile = TRUE,
        family  = "Helvetica",
        pointsize = 12,
        colormodel = "rgb")
        
    vpl <- viewport(x = 0.25, y = 0.5, width = 0.45, height = 0.9)
    pushViewport(vpl)
    grid.rect(gp = gpar(lty = "dashed"))
    popViewport()

    vpr <- viewport(x = 0.75, y = 0.5, width = 0.45, height = 0.9)
    pushViewport(vpr)
    grid.rect(gp = gpar(lty = "dashed"))
    grid.circle(x = 0.6, y = 0.4, r = 0.3)
    popViewport()
    
    dev.off()

In your case you may need to have a viewport of the whole page

see  http://www.amstat.org/publications/jse/v18n3/zhou.pdf for examples

also have a look at the grid.clip function

Regards

Duncan Mackay

Duncan Mackay
Department of Agronomy and Soil Science
University of New England
Armidale NSW 2351
Email: home: mackay at northnet.com.au


-----Original Message-----
From: R-help [mailto:r-help-bounces at r-project.org] On Behalf Of Preetam Pal
Sent: Tuesday, 11 October 2016 19:14
To: r-help at r-project.org
Subject: [R] Output formatting in PDF

Hi,

Can you please help me with the following output formatting:
I am planning to include 2 plots and some general description in a one-page
PDF document, such that

   - I'll leave some appropriate margin on the PDF- say, 1.5 inches
   top,right, bottom and left (will decide based on overall appearance)
   - the 2 plots are placed side-by-side (looks best for comparison)
   - the margins for each plot can be 4 lines on the top and the bottom &
    2 lines on the left and the right
   - each of these 2 plots would have time (0 to 260) along x-axis and two
   time-series (daily USD-GBP and USD-EUR FX rates) on the y-axis, i.e. 2
   time-series would be plotted on each of the 2 graphs. I would need a
   different color for each plot to demarcate them
   - I need to add some text (eg: "Independent analysis of Exchange Rate
   dynamics") with reduced font size (not high priority though-just good to
   have a different size)
   - The general discussion (may be a paragraph) would come right below the
   2 plots - I can specify this text as an argument in a function, may be. I
   am not sure how to arrange the entire PDF as per the format I mentioned
   above

I shall really appreciate any help with this - the time series analysis is
not difficult, I can manage that - however, I don't know how to manage the
formatting part though, so that the 1-pager output looks decently
presentable. Thanks.

Regards,
Preetam

	[[alternative HTML version deleted]]

______________________________________________
R-help at r-project.org mailing list -- To UNSUBSCRIBE and more, see
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.



More information about the R-help mailing list