R/Publication Plots

From QERM Wiki
(Difference between revisions)
Jump to: navigation, search
(Shading Regions on Plots: formatting for code)
(One intermediate revision by one user not shown)
Line 23: Line 23:
== Color ==
== Color ==
See [[R/Colors]].
See [[R/Colors]].
== Shading Regions on Plots ==
* [http://www.alisonsinclair.ca/2011/03/shading-between-curves-in-r/ Here] are some nice examples using the <code>polygon</code> function.
== Text ==
== Text ==

Latest revision as of 19:57, 3 July 2012

Some tips for creating plots for publication



Check with the journal to see if they have file format requirements. You want to use a vector format not a raster format (i.e. pdf not jpg). Your figures will be more reproducible if you use the pdf() and dev.off() commands rather than saving the plot window output.


If possible, check the journal for the size options for figures (i.e 1 column width, full page width, etc.). Use those sizes when you create you figure, so it won't need to be reduced/enlarged. This will almost definitely mean using a smaller cex value than 1. Something like the following will change the baseline cex, but just for that figure:

pdf(file = "figure1.pdf", width = 3, height = 3)
par(cex = 0.7)


Adjust margins so that you don't have a lot of unused white space. This is especially important for multi-panel plots, but if you adjust the margins per panel, make sure that the left/right and top/bottom add up in such a way that the aspect ratio is the same.

Margins can be adjusted using 2 par()settings:

  • mar - specifies the margins in number of lines
  • mai - specifies the margins in inches

You can also specify which line (including fractional lines) axis elements like ticks, tick labels and axis labels are placed on with the par() setting mgp. You can shorten the tick lines with tck. For example,

par(mar = c(3, 3, 0, 0) + 0.1, mgp = c(1.5, 0.5, 0), tck = -0.03 )


See R/Colors.

Shading Regions on Plots

  • Here are some nice examples using the polygon function.


See also

Personal tools