How to set default color to R for all calls to plot.default, plot or lines

To simplify daily R interactions, I would like to set the default colors for all of my stories. For example, let's say I want all graphs to be made with red lines (for example, 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 am I doing here: when the package loads grDevices(downloading the package graphics), I call X11.optionswith my preferred options: wider field, light gray background, xlib calls (because I make remote calls and cairo in my current environment is too slow (another problem for solutions)) I then silently upload the package 3, Defaults, utilsand graphics. The second is necessary to avoid a function error message find.

, setDefaults 3 plot.default. col plot.default, par().

setDefaults par .

...

+5
2

hook "plot.new" par . ( ?plot.new ?setHook)

.Rprofile:

setHook("plot.new", function() par(col = "red"))
+6

, , , , , . , , , :

mydev.new <- function(...) {
  dev.new(...)
  par(col='red')
}

dev.new x11 - , , , . mydev.new, .

,

options(device=mydev.new)

, , , , , . mydev.new ( , ), , .. , , , .

+3

All Articles