to simplify my daily R interactions, I'd like to set up default colors for all my plots. For example, let's say I want to have all plots made with red lines (like in gnuplot...:-) )
So far, here is a snippet of my .Rprofile
setHook(packageEvent("grDevices", "onLoad"),
function(...)
grDevices::X11.options(width = 14, height = 8, type = "Xlib", xpos = 600, ypos = 30, canvas = "grey87"))
suppressPackageStartupMessages( require(Defaults) )
suppressPackageStartupMessages( require(utils) )
suppressPackageStartupMessages( require(graphics) )
setDefaults("plot.default",frame.plot=FALSE, type='l', col=2)
What I do here is the following:
when the grDevices
package is loaded (by loading the graphics
package), I call the X11.options
with my prefered parameters: a wider box, light gray background, xlib calls (because I'm doing distant calls, and cairo in my current environment is just too slow (another problem to solve))
Then I silently load 3 packages, Defaults
, utils
and graphics
. The second one is needed to avoid a find
function error message.
Finally, the magic function setDefaults
set-up 3 parameters to the scatter plot function plot.default
. The 3rd parameter col
is not a parameter of plot.default
but one from the par()
function.
But, doing a setDefaults
call with par
doesn't work either.
Any solution is welcome...
?palette
.... and set defaults onplot.xy
... – Ben Bolkerpar(col="red")
in your .Rprofile? – Sacha Epskamp