Reputation: 4521
I have a few colors (rgb/hex codes) that I would like to be available as defaults. I would like for the colors to be available on startup, without having to run any scripts. In other words, I would like to run the command colors() and have my custom colors show up in the list.
I suspect this list is populated from some file in the R tree, or from some other config file somewhere else. Specifically:
Relevant data:
> version
_
platform x86_64-apple-darwin9.8.0
arch x86_64
os darwin9.8.0
system x86_64, darwin9.8.0
status
major 2
minor 15.1
year 2012
month 06
day 22
svn rev 59600
language R
version.string R version 2.15.1 (2012-06-22)
nickname Roasted Marshmallows
Upvotes: 1
Views: 521
Reputation: 162321
To directly answer your bulleted question: R's color database is stored in the "colors.c" source file.
Because colors()
etc. access compiled versions of that database, you can't add to the named colors without editing the source code and then recompiling R.
Here are the first few lines defining the ColorDataBase in $R_SOURCE_HOME/src/main/colors.c
:
static ColorDataBaseEntry ColorDataBase[] = {
/* name rgb code -- filled in by InitColors() */
{"white", "#FFFFFF", 0},
{"aliceblue", "#F0F8FF", 0},
{"antiquewhite", "#FAEBD7", 0},
{"antiquewhite1", "#FFEFDB", 0},
{"antiquewhite2", "#EEDFCC", 0},
Upvotes: 0
Reputation: 60462
You can (if you really want), change the default palette to your own colours. For example,
(palette(c("yellow", "orange")))
plot(1:10, col=1:10)
Rather than providing named colours, you could also specify rgb colours using the rgb
function. You can add this command to your .Rprofile
so it's available on start-up.
However, a better idea would be to define your own palette:
#Put this in your .Rprofile
mycols = adjustcolor(palette(), alpha.f = 0.3)
palette(mycols)
That way you don't over-ride the default. See ?palette
for other examples.
Upvotes: 3